before_code stringlengths 14 465k | reviewer_comment stringlengths 16 64.5k | after_code stringlengths 9 467k | diff_context stringlengths 0 97k | file_path stringlengths 5 226 | comment_line int32 0 26 | language stringclasses 37
values | quality_score float32 0.07 1 | comment_type stringclasses 9
values | comment_length int32 16 64.5k | before_lines int32 1 17.2k | after_lines int32 1 12.1k | is_negative bool 2
classes | pr_title stringlengths 1 308 | pr_number int32 1 299k | repo_name stringclasses 533
values | repo_stars int64 321 419k | repo_language stringclasses 27
values | reviewer_username stringlengths 0 39 | author_username stringlengths 2 39 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mapping(address => uint256) private _stakeTimestamp;
/* ========== CONSTRUCTOR ========== */
function initialize(
address _owner,
address _rewardsDistribution,
address _rewardsToken,
address _stakingToken,
uint256 _minimumStakeAmount,
uint256 _minimumStakeTi... | As a note, see https://github.com/CryptoBlades/cryptoblades/pull/389#discussion_r675188791. Again, won't actually enforce it for now, so it's just something to keep in mind for the future. | mapping(address => uint256) private _balances;
mapping(address => uint256) private _stakeTimestamp;
// used only by the SKILL-for-SKILL staking contract
CryptoBlades internal __game;
uint256 public override minimumStakeAmount;
/* ========== CONSTRUCTOR ========== */
function initialize(
... | @@ -64,6 +66,7 @@ contract StakingRewardsUpgradeable is
rewardsToken = IERC20(_rewardsToken);
stakingToken = IERC20(_stakingToken);
rewardsDistribution = _rewardsDistribution;
+ minimumStakeAmount = _minimumStakeAmount; | contracts/staking/StakingRewardsUpgradeable.sol | 26 | Solidity | 0.357 | suggestion | 188 | 51 | 51 | false | PVE001: Add minimumStakeAmount to staking contracts | 396 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | brian-man |
// Inheritance
import "./interfaces/IStakingRewards.sol";
import "./RewardsDistributionRecipientUpgradeable.sol";
import "./FailsafeUpgradeable.sol";
// https://docs.synthetix.io/contracts/source/contracts/stakingrewards
contract StakingRewardsUpgradeable is
IStakingRewards,
Initializable,
RewardsDistribu... | New state variables must be added after any and all existing state variables, for proxy contract upgradeability reasons, |
import "../cryptoblades.sol";
// Inheritance
import "./interfaces/IStakingRewards.sol";
import "./RewardsDistributionRecipientUpgradeable.sol";
import "./FailsafeUpgradeable.sol";
// https://docs.synthetix.io/contracts/source/contracts/stakingrewards
contract StakingRewardsUpgradeable is
IStakingRewards,
Ini... | @@ -31,6 +31,7 @@ contract StakingRewardsUpgradeable is
uint256 public periodFinish;
uint256 public override rewardRate;
uint256 public override rewardsDuration;
+ uint256 public override minimumStakeAmount; | contracts/staking/StakingRewardsUpgradeable.sol | 26 | Solidity | 0.357 | suggestion | 120 | 51 | 51 | false | PVE001: Add minimumStakeAmount to staking contracts | 396 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | brian-man |
<template>
<div class="body main-font">
<div v-if="ownCharacters.length === 0" class="blank-slate">
<div class="current-promotion">
<div class="tob-bg-img promotion-decoration">
<img class="vertical-decoration bottom" src="../assets/border-element.png">
</div>
<strong>SIGN... | please don't do uppercase text in code - add a class that does text-transform: uppercase | <template>
<div class="body main-font">
<div v-if="ownCharacters.length === 0" class="blank-slate">
<div class="current-promotion">
<div class="tob-bg-img promotion-decoration">
<img class="vertical-decoration bottom" src="../assets/border-element.png">
</div>
<strong clas... | @@ -2,6 +2,19 @@
<div class="body main-font">
<div v-if="ownCharacters.length === 0" class="blank-slate">
+ <div class="current-promotion">
+ <div class="tob-bg-img promotion-decoration">
+ <img class="vertical-decoration bottom" src="../assets/border-element.png">
+ </div>
+ ... | frontend/src/views/Plaza.vue | 9 | Vue | 0.214 | suggestion | 88 | 34 | 34 | false | feat(plaza): show current sign up bonus on plaza for new players | 408 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | kcper |
</weapon-grid>
<character-list
v-on:character-filters-changed="searchAllCharacterListings(0)"
v-if="activeType === 'character'"
:showFilters="true"
:showGivenCharacterIds="true"
:characterIds="allSearchResults"... | can you do text-transform: uppercase instead of uppercasing the word? |
<template #sold="{ weapon: { id } }">
<div class="sold" v-if="nftPricesById[id] && convertWeiToSkill(nftPricesById[id]) === '0'"><span>sold</span></div>
</template>
</weapon-grid>
<character-list
v-on:character-filters-chan... | @@ -83,12 +83,17 @@
<template #above="{ character: { id } }">
<div class="token-price">
<span class="d-block text-center" v-if="nftPricesById[id]">
- {{ convertWeiToSkill(nftPricesById[id]) | maxDecimals(2) }} SKILL
+ <sp... | frontend/src/views/Market.vue | 26 | Vue | 0.286 | question | 69 | 51 | 51 | false | feat(market): show sold banners over items that are sold but not removed from the DB yet | 409 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | viruspowaa |
export interface IWeaponHistory{
buyerAddress: string
price: number
sellerAddress: string
stat1Element: string
stat1Value: number
stat2Element: string
stat2Value: number
stat3Element: string
stat3Value: number
timestamp: string
type: string
weaponElement: string
weaponId: string
charId: stri... | all of these need semicolons. not sure why the linter isn't picking that up. | export interface IWeaponHistory{
buyerAddress: string;
price: number;
sellerAddress: string;
stat1Element: string;
stat1Value: number;
stat2Element: string;
stat2Value: number;
stat3Element: string;
stat3Value: number;
timestamp: string;
type: string;
weaponElement: string;
weaponId: string;
... | @@ -0,0 +1,42 @@
+export interface IWeaponHistory{
+ buyerAddress: string | frontend/src/interfaces/History.ts | 2 | TypeScript | 0.214 | style | 76 | 27 | 27 | false | feat(market): add sell history popup | 448 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Nyawmeowww |
type SellType = 'weapon' | 'character';
type WeaponId = string;
type CharacterId = string;
type NftId = WeaponId | CharacterId;
interface Data {
activeType: SellType;
search: string;
searchResults: CharacterId[] | WeaponId[];
allSearchResults: CharacterId[] | WeaponId[];
searchResultsOwned: boolean;
selec... | why don't these use IWeaponHistory etc? |
type SellType = 'weapon' | 'character';
type WeaponId = string;
type CharacterId = string;
type NftId = WeaponId | CharacterId;
interface Data {
activeType: SellType;
search: string;
searchResults: CharacterId[] | WeaponId[];
allSearchResults: CharacterId[] | WeaponId[];
searchResultsOwned: boolean;
selec... | @@ -436,13 +494,19 @@ interface Data {
waitingMarketOutcome: boolean;
nftPricesById: Record<string, string>;
characterMarketTax: string;
- weaponMarketTax: string ; characterShowLimit: number;
+ weaponMarketTax: string ;
+ characterShowLimit: number;
weaponShowLimit: number;
allListingsAmount: number... | frontend/src/views/Market.vue | 26 | Vue | 0.143 | question | 39 | 51 | 51 | false | feat(market): add sell history popup | 448 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Nyawmeowww |
) public pure {
uint32[4] memory targets = getTargetsInternal(
getPlayerPower(playerBasePower, wepMultiplier, wepBonusPower),
staminaTimestamp,
hour
);
bool foundMatch = false;
for(uint i = 0; i < targets.length; i++) {
if(targets[i] =... | This will give every single weapon the exact same seed and thus make them identical. The random seed should be combined with `i` and passed to `keccak256()` to make a unique seed for each weapon. | uint24 playerBasePower,
int128 wepMultiplier,
uint24 wepBonusPower,
uint64 staminaTimestamp,
uint256 hour,
uint32 target
) public pure {
uint32[4] memory targets = getTargetsInternal(
getPlayerPower(playerBasePower, wepMultiplier, wepBonusPower),
... | @@ -271,6 +271,49 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
require(foundMatch, "Target invalid");
}
+ mapping (address => uint32) tickets;
+
+ function spendTicket(uint32 num)
+ public
+ {
+ require (tickets[msg.sender] >= num, "You don't have enough t... | contracts/cryptoblades.sol | 26 | Solidity | 0.571 | suggestion | 195 | 51 | 51 | false | Get a free Weapon Forge if you win an Unlikely fight | 494 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | procart |
function verifyFight(
uint24 playerBasePower,
int128 wepMultiplier,
uint24 wepBonusPower,
uint64 staminaTimestamp,
uint256 hour,
uint32 target
) public pure {
uint32[4] memory targets = getTargetsInternal(
getPlayerPower(playerBasePower, wepM... | This should be added in a brand-new contract instead of the main game contract. I'll have to get back to you whether I just make those myself, let another PR create them or have this PR create them. | weaponBonusPower,
timestamp,
getCurrentHour(),
target
);
}
function verifyFight(
uint24 playerBasePower,
int128 wepMultiplier,
uint24 wepBonusPower,
uint64 staminaTimestamp,
uint256 hour,
uint32 target
)... | @@ -271,6 +271,49 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
require(foundMatch, "Target invalid");
}
+ mapping (address => uint32) tickets; | contracts/cryptoblades.sol | 26 | Solidity | 0.429 | suggestion | 198 | 51 | 51 | false | Get a free Weapon Forge if you win an Unlikely fight | 494 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | procart |
private
pure
returns(bool)
{
int128 playerMin = ABDKMath64x64.fromUInt(pp).mul(ABDKMath64x64.fromUInt(90)).div(ABDKMath64x64.fromUInt(100));
int128 playerMax = ABDKMath64x64.fromUInt(pp).mul(ABDKMath64x64.fromUInt(110)).div(ABDKMath64x64.fromUInt(100));
int128 playerR... | This logic probably does not require use of `ABDKMath64x64` to implement at all, and removing all uses of it should lead to huge gas savings. | returns(bool)
{
int128 playerMin = ABDKMath64x64.fromUInt(pp).mul(ABDKMath64x64.fromUInt(90)).div(ABDKMath64x64.fromUInt(100));
int128 playerMax = ABDKMath64x64.fromUInt(pp).mul(ABDKMath64x64.fromUInt(110)).div(ABDKMath64x64.fromUInt(100));
int128 playerRange = playerMax.sub(playerMi... | @@ -271,6 +271,49 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
require(foundMatch, "Target invalid");
}
+ mapping (address => uint32) tickets;
+
+ function spendTicket(uint32 num)
+ public
+ {
+ require (tickets[msg.sender] >= num, "You don't have enough t... | contracts/cryptoblades.sol | 26 | Solidity | 0.571 | suggestion | 141 | 51 | 51 | false | Get a free Weapon Forge if you win an Unlikely fight | 494 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | procart |
weapons.getRandomStat(4, 200, seed, 101),
0, // stat2
0, // stat3
RandomUtil.combineSeeds(seed,102)
);
}
}
function mintWeapon() public onlyNonContract doesNotHaveMoreThanMaxCharacters oncePerBlock(msg.sender) requestPayFromPla... | I don't think `ABDKMath64x64.fromUInt(burnWeaponFee.mulu(burnIDs.length))` will have the desired effect (for example, `3.5 * 3 = 10.5`, which would get rounded off to `10`). Instead I recommend `burnWeaponFee.mul(ABDKMath64x64.fromUInt(burnIDs.length))`.
```suggestion
isWeaponsOwner(burnIDs) requestPayF... | weapons.getRandomStat(4, 200, seed, 101),
0, // stat2
0, // stat3
RandomUtil.combineSeeds(seed,102)
);
}
}
function mintWeapon() public onlyNonContract doesNotHaveMoreThanMaxCharacters oncePerBlock(msg.sender) requestPayFromPla... | @@ -436,6 +436,15 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
weapons.burn(burnID);
}
+ function burnWeapons(uint256[] memory burnIDs) public
+ doesNotHaveMoreThanMaxCharacters
+ isWeaponsOwner(burnIDs) requestPayFromPlayer(ABDKMath64x64.fromUInt(burnWe... | contracts/cryptoblades.sol | 26 | Solidity | 0.857 | suggestion | 489 | 51 | 51 | false | Add contract support for bulk weapon burning | 508 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | brian-man |
// targets expire on the hour
uint256 baseSeed = RandomUtil.combineSeeds(
RandomUtil.combineSeeds(staminaTimestamp,
currentHour),
playerPower
);
uint32[4] memory targets;
for(uint i = 0; i < targets.length; i++) {
// we alter seed... | `requestPayFromPlayer` modifier is going to check against in-game-only SKILL and unclaimed SKILL still. | // targets expire on the hour
uint256 baseSeed = RandomUtil.combineSeeds(
RandomUtil.combineSeeds(staminaTimestamp,
currentHour),
playerPower
);
uint32[4] memory targets;
for(uint i = 0; i < targets.length; i++) {
// we alter seed... | @@ -390,7 +390,7 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
function mintCharacter() public onlyNonContract doesNotHaveMoreThanMaxCharacters oncePerBlock(msg.sender) requestPayFromPlayer(mintCharacterFee) { | contracts/cryptoblades.sol | 26 | Solidity | 0.5 | suggestion | 103 | 51 | 51 | false | in-game-only funds no longer allowed for mintCharacter | 523 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | zBNF |
}
function payPlayerConverted(address playerAddress, uint256 convertedAmount) public restricted {
_payPlayerConverted(playerAddress, convertedAmount);
}
function approveContractCharacterFor(uint256 characterID, address playerAddress) public restricted {
_approveContractCharacterFor(cha... | `convertedAmount` should be `fromUserWallet` here. | }
function payPlayerConverted(address playerAddress, uint256 convertedAmount) public restricted {
_payPlayerConverted(playerAddress, convertedAmount);
}
function approveContractCharacterFor(uint256 characterID, address playerAddress) public restricted {
_approveContractCharacterFor(cha... | @@ -512,6 +523,20 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
_approveContractWeaponFor(weaponID, playerAddress);
}
+ function _payContractTokenOnly(address playerAddress, int128 usdAmount) internal {
+ uint256 convertedAmount = usdToSkill(usdAmount);
+
+ (, ui... | contracts/cryptoblades.sol | 26 | Solidity | 0.429 | suggestion | 50 | 51 | 51 | false | in-game-only funds no longer allowed for mintCharacter | 523 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | zBNF |
defaultCallOptions(state),
defaultCallOptions(state),
cryptoBladesMethods => cryptoBladesMethods.mintCharacterFee()
);
await state.contracts().CryptoBlades!.methods.mintCharacter().send(defaultCallOptions(state));
await Promise.all([
dispatch('fetchFight... | This will only approve enough SKILL for 1 weapon, not `num` weapons. | defaultCallOptions(state),
defaultCallOptions(state),
cryptoBladesMethods => cryptoBladesMethods.mintCharacterFee()
);
await state.contracts().CryptoBlades!.methods.mintCharacter().send(defaultCallOptions(state));
await Promise.all([
dispatch('fetchFight... | @@ -953,6 +953,34 @@ export function createStore(web3: Web3) {
]);
},
+ async mintWeaponN({ state, dispatch }, {num}) {
+ if(featureFlagStakeOnly || !state.defaultAccount) return;
+
+ await approveFee(
+ state.contracts().CryptoBlades!,
+ state.contracts().SkillTok... | frontend/src/store.ts | 26 | TypeScript | 0.357 | suggestion | 68 | 51 | 51 | false | Add fuction to mint N amount of weapons | 539 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | procart |
if(!promos.getBit(msg.sender, promos.BIT_FIRST_CHARACTER()) && characters.balanceOf(msg.sender) == 0) {
_giveInGameOnlyFundsFromContractBalance(msg.sender, usdToSkill(promos.firstCharacterPromoInGameOnlyFundsGivenInUsd()));
}
uint256 seed = randoms.getRandomSeed(msg.sender);
... | Better be safe than sorry and just enforce a maximum value as well. Can be changed easily later on anyway. | if(!promos.getBit(msg.sender, promos.BIT_FIRST_CHARACTER()) && characters.balanceOf(msg.sender) == 0) {
_giveInGameOnlyFundsFromContractBalance(msg.sender, usdToSkill(promos.firstCharacterPromoInGameOnlyFundsGivenInUsd()));
}
uint256 seed = randoms.getRandomSeed(msg.sender);
... | @@ -433,6 +433,20 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
}
}
+ function mintWeaponN(uint32 num)
+ public
+ onlyNonContract
+ oncePerBlock(msg.sender)
+ requestPayFromPlayer(mintWeaponFee * num)
+ {
+ require(num > 0); | contracts/cryptoblades.sol | 26 | Solidity | 0.429 | suggestion | 106 | 51 | 51 | false | Add fuction to mint N amount of weapons | 539 | CryptoBlades/cryptoblades | 321 | Vue | raymond-h | procart |
console.error(e);
this.error = e.message;
}
},
formattedSkill(skill) {
const skillBalance = fromWeiEther(skill, 'ether');
return `${toBN(skillBalance).toFixed(6)} SKILL`;
},
getPotentialXp(targetToFight) {
const characterPower = CharacterPower(this.currentCharac... | this needs to be done way better, there is too much repetitive code here. I will assist. | console.error(e);
this.error = e.message;
}
},
formattedSkill(skill) {
const skillBalance = fromWeiEther(skill, 'ether');
return `${toBN(skillBalance).toFixed(6)} SKILL`;
},
getPotentialXp(targetToFight) {
const characterPower = CharacterPower(this.currentCharac... | @@ -343,6 +329,54 @@ export default {
setFightMultiplier() {
localStorage.setItem('fightMultiplier', this.fightMultiplier.toString());
},
+
+ setStaminaSelectorValues(){ | frontend/src/views/Combat.vue | 26 | Vue | 0.286 | suggestion | 88 | 51 | 51 | false | fix(combat): disallow bad stamina values for fight | 540 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | 0xroy |
return tokens;
}
function getMyWeapons() public view returns(uint256[] memory) {
uint256[] memory tokens = new uint256[](weapons.balanceOf(msg.sender));
for(uint256 i = 0; i < tokens.length; i++) {
tokens[i] = weapons.tokenOfOwnerByIndex(msg.sender, i);
}
ret... | I have no idea how this got reverted, but be more careful in the future | return tokens;
}
function getMyWeapons() public view returns(uint256[] memory) {
uint256[] memory tokens = new uint256[](weapons.balanceOf(msg.sender));
for(uint256 i = 0; i < tokens.length; i++) {
tokens[i] = weapons.tokenOfOwnerByIndex(msg.sender, i);
}
ret... | @@ -209,7 +209,7 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
// isCharacterOwner(char)
// isWeaponOwner(wep) {
fightModifierChecks(char, wep) {
- require(fightMultiplier >= 1 && fightMultiplier <= 5);
+ require(fightMultiplier > 0); | contracts/cryptoblades.sol | 26 | Solidity | 0.214 | suggestion | 71 | 51 | 51 | false | feat(blacksmith): revamp reforge ui | 578 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Sellie96 |
}
function performMintWeapon(address minter,
uint16 properties,
uint16 stat1, uint16 stat2, uint16 stat3,
uint256 cosmeticSeed
) public restricted returns(uint256) {
uint256 tokenID = tokens.length;
if(block.number != lastMintedBlock)
firstMintedOfLastB... | "chosen" also we really should not use 4 as the sentinel value for this; it should be higher, like 100. We don't plan to add more elements, but if we did, we don't want to have to redo this as well. | (uint16 stat1, uint16 stat2, uint16 stat3) = getStatRolls(stars, seed);
return performMintWeapon(minter,
getRandomProperties(stars, seed, chosenElement),
stat1,
stat2,
stat3,
RandomUtil.combineSeeds(seed,3)
);
}
function perfo... | @@ -236,9 +236,15 @@ contract Weapons is Initializable, ERC721Upgradeable, AccessControlUpgradeable {
return tokenID;
}
- function getRandomProperties(uint256 stars, uint256 seed) public pure returns (uint16) {
+ function getRandomProperties(uint256 stars, uint256 seed, uint256 choosenElement) pub... | contracts/weapons.sol | 26 | Solidity | 0.429 | suggestion | 198 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | 0xroy |
if (this.hideWalletWarning) localStorage.setItem('hideWalletWarning', 'true');
else localStorage.setItem('hideWalletWarning', 'false');
Events.$emit('setting:hideWalletWarning', { value: this.hideWalletWarning });
},
async showWarningDialog() {
await new Promise((resolve) => setTimeout... | this was intentional, please revert it | },
toggleHideWalletWarning() {
this.hideWalletWarning = !this.hideWalletWarning;
if (this.hideWalletWarning) localStorage.setItem('hideWalletWarning', 'true');
else localStorage.setItem('hideWalletWarning', 'false');
Events.$emit('setting:hideWalletWarning', { value: this.hideWalletWar... | @@ -311,7 +310,7 @@ export default {
},
async checkNotifications() {
- const response = await fetch(apiUrl('static/notifications'));
+ const response = await fetch('https://api.cryptoblades.io/static/notifications'); | frontend/src/App.vue | 26 | Vue | 0.071 | suggestion | 38 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | 0xroy |
x10 ({{ forgeCost*10 }} SKILL) <i class="fas fa-plus"></i>
</span>
</b-button>
<b-icon-question-circle class="centered-icon" scale="1.5"
v-on:click="onShowForgeDetails" v-tooltip.bottom="'Click for forge percentages'"/>
<b-modal hide-foot... | do not use the comma operator. make this a function. | <b-checkbox
variant="primary"
class="mx-3 my-auto"
:disabled="disableUseStakedForForge"
v-model="useStakedForForge">
<span v-if="disableUseStakedForForge"> <b>Not enough staked SKILL<br></b></span>
... | @@ -79,17 +79,51 @@
1+ star @ 100% chance.
</div>
</b-modal>
+
+ <b-modal hide-footer ref="forge-element-selector-modal" title="Select Element" @hide="disableConfirmButton = true, forgeCostMultiplier = null"> | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.286 | suggestion | 52 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | 0xroy |
<div>
5+ star @ 1% chance. Estimated cost {{Number.parseFloat(forgeCost * (1/0.01)).toFixed(2)}} SKILL.
</div>
<div>
4+ star @ 6% chance. Estimated cost {{Number.parseFloat(forgeCost * (1/0.06)).toFixed(2)}} SKILL.
</div>
... | do not use style attributes. use CSS. | <b-icon-question-circle class="centered-icon" scale="1.5"
v-on:click="onShowForgeDetails" v-tooltip.bottom="'Click for forge percentages'"/>
<b-modal hide-footer ref="forge-details-modal" title="Forge Percentages">
<div>
5+ star @ ... | @@ -79,17 +79,51 @@
1+ star @ 100% chance.
</div>
</b-modal>
+
+ <b-modal hide-footer ref="forge-element-selector-modal" title="Select Element" @hide="disableConfirmButton = true, forgeCostMultiplier = null">
+ <div class="row justify-content-md-cente... | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.143 | style | 37 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | 0xroy |
v-tooltip="'Forge new weapon'">
<span v-if="!disableForge" class="gtag-link-others" tagname="forge_weapon">
Forge ({{Number.parseFloat(forgeCost * this.forgeCostMultiplier).toFixed(2)}} SKILL)
</span>
</b-button>
<b-... | do not revert these text changes | variant="primary"
class="row justify-content-md-center"
@click="onForgeWeapon"
:disabled="disableConfirmButton"
v-tooltip="'Forge new weapon'">
<span v-if="!disableForge" class="gtag-lin... | @@ -79,17 +79,51 @@
1+ star @ 100% chance.
</div>
</b-modal>
+
+ <b-modal hide-footer ref="forge-element-selector-modal" title="Select Element" @hide="disableConfirmButton = true, forgeCostMultiplier = null">
+ <div class="row justify-content-md-cente... | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.143 | suggestion | 32 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | 0xroy |
this.viewNewWeapons(this.forgeMultiplier);
} catch (e) {
console.error(e);
this.onError = true;
this.$dialog.notify.error('Could not forge sword: insuffucient funds or transaction denied.');
}
},
onShowForgeDetails() {
this.$refs['forge-details-modal'].show();... | don't do this. cast it to an array so you don't have to call it like this. also, use arrow functions. | <div class="col-md-5 weapon-container" align="center">
<h1 class="text-center">Select the weapon you wish to burn</h1>
<weapon-grid v-model="burnWeaponId" :ignore="burnWeaponIds"
:showGivenWeaponIds="true" :weaponIds="hideWeapons" @choosewe... | @@ -261,6 +303,25 @@ export default {
this.$refs['forge-details-modal'].show();
},
+ onClickForge(i) {
+ this.chlickedForgeButton = i;
+ this.$refs['forge-element-selector-modal'].show();
+ },
+
+ setChoosenElement(ele, i) {
+ this.selectedElement = i;
+ if (i === 4) {
+ ... | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.571 | suggestion | 101 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | 0xroy |
this.disableForge = false;
}, 10000);
try {
await this.mintWeaponN({num: this.forgeMultiplier, chosenElement: this.selectedElement, chosenElementFee: this.chosenElementFee});
this.viewNewWeapons(this.forgeMultiplier);
} catch (e) {
console.error(e);
this.onEr... | this could be `this.chosenElementFee = i === 100 ? 1 : 2;` | <div class="row mt-3">
<div class="col-md-12" v-if="showReforge && showReforgeDust === false">
<div>
<div class="col-md-12">
<div class="row mobile-flip">
<div class="col-md-5 weapon-container" align="center">
<h1 class="t... | @@ -304,18 +304,18 @@ export default {
},
onClickForge(i) {
- this.chlickedForgeButton = i;
+ this.clickedForgeButton = i;
this.$refs['forge-element-selector-modal'].show();
},
setChoosenElement(ele, i) {
this.selectedElement = i;
- if (i === 4) {
- this.forge... | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.429 | suggestion | 58 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | 0xroy |
}
function mint(address minter, uint256 seed, uint16 chosenElement) public restricted returns(uint256) {
uint256 stars;
uint256 roll = seed % 100;
// will need revision, possibly manual configuration if we support more than 5 stars
if(roll < 1) {
stars = 4; // 5* at ... | Weapon trait is uint8 originally, I think it's better to keep it matching. | }
function mint(address minter, uint256 seed, uint8 chosenElement) public restricted returns(uint256) {
uint256 stars;
uint256 roll = seed % 100;
// will need revision, possibly manual configuration if we support more than 5 stars
if(roll < 1) {
stars = 4; // 5* at 1... | @@ -208,15 +208,15 @@ contract Weapons is Initializable, ERC721Upgradeable, AccessControlUpgradeable {
stars = 0; // 1* at 44%
}
- return mintWeaponWithStars(minter, stars, seed);
+ return mintWeaponWithStars(minter, stars, seed, chosenElement);
}
- function mintWeaponWit... | contracts/weapons.sol | 26 | Solidity | 0.286 | suggestion | 74 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | kcper | 0xroy |
RandomUtil.combineSeeds(seed,3)
);
}
function performMintWeapon(address minter,
uint16 properties,
uint16 stat1, uint16 stat2, uint16 stat3,
uint256 cosmeticSeed
) public restricted returns(uint256) {
uint256 tokenID = tokens.length;
if(block.nu... | Weapon trait is uint8 originally, I think it's better to keep it matching. | RandomUtil.combineSeeds(seed,3)
);
}
function performMintWeapon(address minter,
uint16 properties,
uint16 stat1, uint16 stat2, uint16 stat3,
uint256 cosmeticSeed
) public restricted returns(uint256) {
uint256 tokenID = tokens.length;
if(block.nu... | @@ -245,9 +245,15 @@ contract Weapons is Initializable, ERC721Upgradeable, AccessControlUpgradeable {
return tokenID;
}
- function getRandomProperties(uint256 stars, uint256 seed) public pure returns (uint16) {
+ function getRandomProperties(uint256 stars, uint256 seed, uint16 chosenElement) publi... | contracts/weapons.sol | 26 | Solidity | 0.286 | suggestion | 74 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | kcper | 0xroy |
mintPaymentSkillDepositeds[_minter].skillDepositedFromWallet = 0;
mintPaymentSkillDepositeds[_minter].skillDepositedFromRewards = 0;
mintPaymentSkillDepositeds[_minter].skillDepositedFromIgo = 0;
}
function mintWeapon(uint256 chosenElement) public onlyNonContract oncePerBlock(msg.sender... | Needs check on chosenElementFee value to prevent passing 0 as chosenElementFee there and minting weapons for free with `line 720: _payContract(msg.sender, mintWeaponFee * num * 0);`
Update: I'd say don't pass chosenElementFee to this function at all and determine what it's value should be based on chosenElement. As... | }
/*function mintWeaponN(uint32 num)
public
onlyNonContract
oncePerBlock(msg.sender)
{
require(num > 0 && num <= 1000);
_discardPaymentIfExpired(msg.sender);
require(mintPayments[msg.sender].count == num, "count mismatch");
// the function below is e... | @@ -711,24 +711,24 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
}
}*/
- function mintWeaponN(uint32 num)
+ function mintWeaponN(uint32 num, uint16 chosenElement, uint16 chosenElementFee) | contracts/cryptoblades.sol | 26 | Solidity | 0.643 | suggestion | 421 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | kcper | 0xroy |
mintPaymentSkillDepositeds[msg.sender].skillDepositedFromWallet = 0;
mintPaymentSkillDepositeds[msg.sender].skillDepositedFromRewards = 0;
mintPaymentSkillDepositeds[msg.sender].skillDepositedFromIgo = 0;
emit MintWeaponsSuccess(msg.sender, 1);
}
catch {... | Same chosenElementFee vulnerability here. | emit MintWeaponsSuccess(msg.sender, num);
}
catch {
emit MintWeaponsFailure(msg.sender, num);
}
}
function _mintWeaponNUsableByThisOnlyButExternalForReasons(address _minter, uint32 num, uint256 chosenElement) external {
// the reason referred to in the fu... | @@ -711,24 +711,24 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
}
}*/
- function mintWeaponN(uint32 num)
+ function mintWeaponN(uint32 num, uint16 chosenElement, uint16 chosenElementFee)
public
onlyNonContract
oncePerBlock(msg.sender)
{
... | contracts/cryptoblades.sol | 26 | Solidity | 0.071 | security | 41 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | kcper | 0xroy |
uint8 chosenElementFee = chosenElement == 100 ? 1 : 2;
_payContract(msg.sender, mintWeaponFee * num * chosenElementFee);
for (uint i = 0; i < num; i++) {
weapons.mint(msg.sender, uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), msg.sender, i))), chosenElement);
... | I just noticed and I think we should only allow passing 0, 1, 2, 3, 100 as chosenElement, other values are not supported and could cause unexpected behavior.
Please create a modifier to check for supported elements and apply to both mint functions.
Something along those lines:
```
modifier isSupportedElement(uint8 ... | mintPaymentSkillDepositeds[_minter].skillDepositedFromWallet = 0;
mintPaymentSkillDepositeds[_minter].skillDepositedFromRewards = 0;
mintPaymentSkillDepositeds[_minter].skillDepositedFromIgo = 0;
}
function mintWeapon(uint256 chosenElement) public onlyNonContract oncePerBlock(msg.sender... | @@ -711,20 +711,25 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
}
}*/
- function mintWeaponN(uint32 num, uint16 chosenElement, uint16 chosenElementFee)
+ function mintWeaponN(uint32 num, uint8 chosenElement) | contracts/cryptoblades.sol | 26 | Solidity | 0.857 | suggestion | 795 | 51 | 51 | false | feature choose weapon element on forge | 582 | CryptoBlades/cryptoblades | 321 | Vue | kcper | 0xroy |
}
}
}
function hasPaidForMint() public view returns(bool){
return (mintPayments[msg.sender].count > 0);
}
function payForMint(address nftAddress, uint count) public {
_discardPaymentIfExpired();
require(mintPayments[msg.sender].count == 0);
require... | we may want the .count check to be == instead of >=.
Imagine paying for 10 mints, then for some reason deciding to use the 2nd step for the 1x mint. | function hasPaidForMint(uint32 _num) public view returns(bool){
require(_num > 0);
return (
mintPayments[msg.sender].count == _num && (
mintPayments[msg.sender].blockHash != 0 ||
mintPayments[msg.sender].blockNumber + MINT_PAYMENT_TIMEOUT >= block.number
... | @@ -451,6 +460,60 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
return (((attacker + 1) % 4) == defender); // Thanks to Tourist
}
+ function _updatePaymentBlockHash() internal {
+ if ((mintPayments[msg.sender].count > 0) &&
+ (mintPayments[msg.sender].blockHa... | contracts/cryptoblades.sol | 26 | Solidity | 0.429 | suggestion | 149 | 51 | 51 | false | Change seed handling for mintWeapon and mintWeaponN | 624 | CryptoBlades/cryptoblades | 321 | Vue | poshdan | brian-man |
if (mintPayments[msg.sender].blockHash == 0) {
delete mintPayments[msg.sender];
}
}
}
function hasPaidForMint() public view returns(bool){
return (mintPayments[msg.sender].count > 0);
}
function payForMint(address nftAddress, uint count) public {... | I wonder if the discardIfExpired call is necessary if the try portion is to succeed | }
function hasPaidForMint(uint32 _num) public view returns(bool){
require(_num > 0);
return (
mintPayments[msg.sender].count == _num && (
mintPayments[msg.sender].blockHash != 0 ||
mintPayments[msg.sender].blockNumber + MINT_PAYMENT_TIMEOUT >= block.n... | @@ -451,6 +460,60 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
return (((attacker + 1) % 4) == defender); // Thanks to Tourist
}
+ function _updatePaymentBlockHash() internal {
+ if ((mintPayments[msg.sender].count > 0) &&
+ (mintPayments[msg.sender].blockHa... | contracts/cryptoblades.sol | 26 | Solidity | 0.214 | suggestion | 83 | 51 | 51 | false | Change seed handling for mintWeapon and mintWeaponN | 624 | CryptoBlades/cryptoblades | 321 | Vue | poshdan | brian-man |
| (uint32(indexSeed % 4) << 24) // trait
);
}
return targets;
}
function isTraitEffectiveAgainst(uint8 attacker, uint8 defender) public pure returns (bool) {
return (((attacker + 1) % 4) == defender); // Thanks to Tourist
}
function _updatePaymentBl... | we probably want to do the blockhash update in the catch part of the minting code? | | (uint32(indexSeed % 4) << 24) // trait
);
}
return targets;
}
function isTraitEffectiveAgainst(uint8 attacker, uint8 defender) public pure returns (bool) {
return (((attacker + 1) % 4) == defender); // Thanks to Tourist
}
function _updatePaymentBl... | @@ -451,6 +460,60 @@ contract CryptoBlades is Initializable, AccessControlUpgradeable {
return (((attacker + 1) % 4) == defender); // Thanks to Tourist
}
+ function _updatePaymentBlockHash() internal {
+ if ((mintPayments[msg.sender].count > 0) &&
+ (mintPayments[msg.sender].blockHa... | contracts/cryptoblades.sol | 26 | Solidity | 0.214 | question | 82 | 51 | 51 | false | Change seed handling for mintWeapon and mintWeaponN | 624 | CryptoBlades/cryptoblades | 321 | Vue | poshdan | brian-man |
this.getCurrentListofWeapons();
this.onError = false;
this.x1Forge = true;
this.disableForge = true;
// Incase the network or mm are having issues, after 1 min we reshow
const failbackTimeout = setTimeout(() => {
this.disableForge = false;
}, 60000);
try {
... | this is debugging stuff, remove it | const failbackTimeout = setTimeout(() => {
this.disableForge = false;
}, 30000);
try {
await this.mintWeapon();
} catch (e) {
console.error(e);
this.$dialog.notify.error('Could not forge sword: insuffucient funds or transaction denied.');
} finally {
... | @@ -246,13 +246,20 @@ export default {
try {
await this.mintWeapon();
- this.viewNewWeapons(1);
-
} catch (e) {
console.error(e);
- this.onError = true;
this.$dialog.notify.error('Could not forge sword: insuffucient funds or transaction denied.');
} finall... | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.286 | bug | 34 | 51 | 51 | false | feat(x10forge) | 629 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Nyawmeowww |
},
isWeaponRare() {
return this.getWeaponToBurn().stars >= 3;
},
isWeaponReforged() {
return this.getWeaponToBurn().bonusPower > 0;
},
getWeaponToBurn() {
return this.ownWeapons.find(x => x.id === this.burnWeaponId);
},
getCurrentListofWeapons(){
this.ownedWea... | never check against true, just check if(this.x1Forge). perhaps instead, do `this.forgeAmount = 1 or 10` and check that. but really, this should be a number and you should do the math based on that number. | this.newForged = [];
this.ownedWeaponIds.forEach(x => {
this.newForged.push(x);
});
this.newForged.splice(0, this.ownedWeaponIds.length - offset + 1);
// eslint-disable-next-line no-constant-condition
if (this.newForged.length > 0 && !this.onError){
this.spin = tru... | @@ -311,8 +325,17 @@ export default {
});
},
- viewNewWeapons(newWeaponCount = 1){
- this.newForged = this.ownedWeaponIds.slice(-newWeaponCount);
+ viewNewWeapons(){
+ this.newForged = [];
+ this.ownedWeaponIds.forEach(x => {
+ this.newForged.push(x);
+ });
+ if(this.... | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.643 | suggestion | 204 | 51 | 51 | false | feat(x10forge) | 629 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Nyawmeowww |
},
isWeaponRare() {
return this.getWeaponToBurn().stars >= 3;
},
isWeaponReforged() {
return this.getWeaponToBurn().bonusPower > 0;
},
getWeaponToBurn() {
return this.ownWeapons.find(x => x.id === this.burnWeaponId);
},
getCurrentListofWeapons(){
this.ownedWea... | why do this - use forgeMultiplier to do the math for splicing | return this.ownWeapons.find(x => x.id === this.burnWeaponId);
},
viewNewWeapons(offset){
this.newForged = [];
this.ownedWeaponIds.forEach(x => {
this.newForged.push(x);
});
this.newForged.splice(0, this.ownedWeaponIds.length - offset + 1);
// eslint-disable-next-l... | @@ -330,10 +326,10 @@ export default {
this.ownedWeaponIds.forEach(x => {
this.newForged.push(x);
});
- if(this.x1Forge === true){
+ if(this.forgeMultiplier === 1){ | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.286 | suggestion | 61 | 51 | 51 | false | feat(x10forge) | 629 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Nyawmeowww |
this.$refs['forge-details-modal'].show();
},
showReforgeConfirmation() {
this.$refs['reforge-confirmation-modal'].show();
},
isWeaponRare() {
return this.getWeaponToBurn().stars >= 3;
},
isWeaponReforged() {
return this.getWeaponToBurn().bonusPower > 0;
},
get... | this really holds no purpose. I will fix and merge | this.$refs['forge-details-modal'].show();
},
showReforgeConfirmation() {
this.$refs['reforge-confirmation-modal'].show();
},
isWeaponRare() {
return this.getWeaponToBurn().stars >= 3;
},
isWeaponReforged() {
return this.getWeaponToBurn().bonusPower > 0;
},
get... | @@ -305,14 +304,16 @@ export default {
return this.ownWeapons.find(x => x.id === this.burnWeaponId);
},
- getCurrentListofWeapons(){
+ viewNewWeapons(offset){
+ this.newForged = [];
this.ownedWeaponIds.forEach(x => {
- this.currentListofWeapons.push(x);
+ this.newForged.pus... | frontend/src/views/Blacksmith.vue | 26 | Vue | 0.214 | suggestion | 50 | 51 | 51 | false | feat(x10forge) | 629 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Nyawmeowww |
import swordspecs from '../assets/swordspecs.json';
import maskChroma from '../shaders/maskchroma_frag.glsl.js';
import '@/mixins/general';
import { Stat1PercentForChar,
Stat2PercentForChar,
Stat3PercentForChar
} from '../interfaces';
import { mapGetters, mapState } from 'vuex';
import { CensorSensor } from 'censo... | can this get abstracted to a separate service or somewhere else it can be imported? like the getWeaponNameFromSeed function etc. Then we have one function we can call everywhere instead of initializing this everywhere. If we want to update the profanity we then also have one file we have to do so. | import swordspecs from '../assets/swordspecs.json';
import maskChroma from '../shaders/maskchroma_frag.glsl.js';
import '@/mixins/general';
import { Stat1PercentForChar,
Stat2PercentForChar,
Stat3PercentForChar
} from '../interfaces';
import { mapGetters, mapState } from 'vuex';
import { getCleanName } from '../re... | @@ -88,6 +88,8 @@ const gColor = new Three.Color(0x413F41);
const bColor = new Three.Color(0xAF5822);
const white = new Three.Color(0xFFFFFF);
+const censor = new CensorSensor(); | frontend/src/components/WeaponIcon.vue | 26 | Vue | 0.5 | refactor | 298 | 51 | 51 | false | fix(ui): run censor on names to filter profanity | 659 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | kcper |
function(error) {
console.error(error);
},
);
}
this.setupModel();
},
clearScene() {
if (this.scene !== undefined && this.scene !== null) {
this.scene.clear();
this.renderer.render(this.scene, this.camera);
}
},
setupLighti... | is there a reason this can't be `if(!this.scene)`? | function(error) {
console.error(error);
},
);
}
this.setupModel();
},
clearScene() {
if (this.scene !== undefined && this.scene !== null) {
this.scene.clear();
this.renderer.render(this.scene, this.camera);
}
},
setupLighti... | @@ -231,6 +231,7 @@ export default {
this.scene.add(light);
},
setupModel() {
+ if(this.scene === null || this.scene === undefined) return; | frontend/src/components/CharacterArt.vue | 26 | Vue | 0.357 | question | 50 | 51 | 51 | false | Raid UI patch | 694 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | kcper |
startIndex,
endIndex
});
},
promptRewardClaim(): void {
// should offer a popup here to pick which index to claim
// if only one index, then claim instantly
if(this.rewardIndexes !== null && this.rewardIndexes.length > 0) {
if(this.rewardIndexes.length === 1) {
... | This type should be NftIdType[]. Actual Nfts are fetched in NftList component based on id and type. While this will work as is, I think it might introduce some confusion.
Here's a prop in NftList.vue that the collection created here is passed to:
```
nftIdTypes: {
type: Array as PropType<NftIdType[]>,
defaul... | endIndex
});
},
promptRewardClaim(): void {
// should offer a popup here to pick which index to claim
// if only one index, then claim instantly
if(this.rewardIndexes !== null && this.rewardIndexes.length > 0) {
if(this.rewardIndexes.length === 1) {
this.claimR... | @@ -385,89 +423,89 @@ export default {
});
},
- promptRewardClaim() {
+ promptRewardClaim(): void {
// should offer a popup here to pick which index to claim
// if only one index, then claim instantly
if(this.rewardIndexes !== null && this.rewardIndexes.length > 0) {
if... | frontend/src/views/Raid.vue | 26 | Vue | 1 | suggestion | 356 | 51 | 51 | false | Raid.vue rewrite to Typescript | 711 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
return this.contracts.Characters!;
},
Shields(): Contract<Shields> {
// we use x! here because we assert that they're set already in created()
// this helps with typings
return this.contracts.Shields!;
},
contractAddress(): string {
return this.nftType === 'weapon'
... | Why is this async? Similar functions below are not. | return this.contracts.Characters!;
},
Shields(): Contract<Shields> {
// we use x! here because we assert that they're set already in created()
// this helps with typings
return this.contracts.Shields!;
},
contractAddress(): string {
return this.nftType === 'weapon'
... | @@ -0,0 +1,339 @@
+<template>
+ <div>
+ <div class="row row-cols-2 nft-display">
+ <div class="col-12 col-md-4 search-section">
+ <div class="row search-row-section">
+ <div class="col">
+ <h1>Search for NFT</h1>
+ </div>
+ <div class="col">
+ <div class=... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.214 | question | 52 | 51 | 51 | false | NFT Display Page | 723 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
"
>
<span class="d-block text-center fix-h24" v-if="nftPriceInSkill() !== '0'">
<span
v-if="nftPriceInSkill() !== '0'"
v-tooltip.top="{
content: maxPrecisionSkill(nftPrice),
... | The condition is already in v-if of this b-button. Condition here won't have any effect - does it break any functionality (Puchase/Sold text)? | "
>
<span
class="d-block text-center fix-h24"
v-if="nftPriceInSkill() !== '0'"
>
<span
v-tooltip.top="{
content: maxPrecisionSkill(nftPrice),
... | @@ -46,22 +46,147 @@
:showFavoriteWeaponsDefVal="false"
:canFavorite="false"
:newWeapon="true"
- />
+ >
+ <template #above="{ weapon: { id } }">
+ <div
+ class="
+ d-flex
+ flex-column
+ ... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.357 | question | 142 | 51 | 51 | false | NFT display page market integration | 727 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
Characters(): Contract<Characters> {
// we use x! here because we assert that they're set already in created()
// this helps with typings
return this.contracts.Characters!;
},
Shields(): Contract<Shields> {
// we use x! here because we assert that they're set already in created()
... | No need to check nftType against 'weapon' and 'shield' when canPurchase is used only in characters-list template. The first 2 conditiosn can be removed. | // this helps with typings
return this.contracts.Weapons!;
},
Characters(): Contract<Characters> {
// we use x! here because we assert that they're set already in created()
// this helps with typings
return this.contracts.Characters!;
},
Shields(): Contract<Shields> {
... | @@ -175,6 +318,13 @@ export default Vue.extend({
? this.Characters.options.address
: this.Shields.options.address;
},
+ canPurchase(): boolean {
+ return (
+ this.nftType === 'weapon' ||
+ this.nftType === 'shield' ||
+ this.ownCharacters.length < 4
+ );
+ ... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.571 | suggestion | 152 | 51 | 51 | false | NFT display page market integration | 727 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
text = window.location.href;
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand('copy');
document.body.removeChild(dummy);
},
convertWeiToSkill(wei: string): string {
return fromWeiEther(wei);
},
maxPrecisionSkill(listed... | I need some clarification here. When purchasing we want to check if displayed price equals price on chain. Here you read price from chain and assign it to UI price to later on check if they are the same. This is confusing, because now they will always be the same even though they could be different before you reassigne... | text = window.location.href;
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand('copy');
document.body.removeChild(dummy);
},
convertWeiToSkill(wei: string): string {
return fromWeiEther(wei);
},
maxPrecisionSkill(listed... | @@ -245,6 +399,90 @@ export default Vue.extend({
document.execCommand('copy');
document.body.removeChild(dummy);
},
+ convertWeiToSkill(wei: string): string {
+ return fromWeiEther(wei);
+ },
+ maxPrecisionSkill(listedPrice: string): string {
+ return this.convertStringToDecimal(
+... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.643 | suggestion | 398 | 51 | 51 | false | NFT display page market integration | 727 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
if (this.nftId === null) return;
const price = await this.lookupNftPrice(this.nftId);
if (price) {
this.nftPrice = price;
} else {
return;
}
const skillChainPrice = this.convertStringToDecimal(
this.convertWeiToSkill(price),
2
);
const sk... | This is not used at all. Either use it in template to show some kind of loading or remove. |
const price = await this.lookupNftPrice(this.nftId);
if (!price) return;
const skillChainPrice = this.convertStringToDecimal(
this.convertWeiToSkill(price),
2
);
const skillUIPrice = this.convertStringToDecimal(
this.nftPriceInSkill(),
2
);
if... | @@ -245,6 +399,90 @@ export default Vue.extend({
document.execCommand('copy');
document.body.removeChild(dummy);
},
+ convertWeiToSkill(wei: string): string {
+ return fromWeiEther(wei);
+ },
+ maxPrecisionSkill(listedPrice: string): string {
+ return this.convertStringToDecimal(
+... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.286 | suggestion | 90 | 51 | 51 | false | NFT display page market integration | 727 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
const skillUIPrice = this.convertStringToDecimal(
this.nftPriceInSkill(),
2
);
if (skillChainPrice !== skillUIPrice) {
(this as any).$dialog.notify.error(
'The price of the listing has changed. Please refresh listing and try again'
);
return;
}
... | Can't see marketOutcome being used/displayed anywhere either. | if (skillChainPrice !== skillUIPrice) {
(this as any).$dialog.notify.error(
'The price of the listing has changed. Please refresh listing and try again'
);
return;
}
await this.purchaseMarketListing({
nftContractAddr: this.contractAddress,
tokenId: th... | @@ -245,6 +399,90 @@ export default Vue.extend({
document.execCommand('copy');
document.body.removeChild(dummy);
},
+ convertWeiToSkill(wei: string): string {
+ return fromWeiEther(wei);
+ },
+ maxPrecisionSkill(listedPrice: string): string {
+ return this.convertStringToDecimal(
+... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.286 | suggestion | 61 | 51 | 51 | false | NFT display page market integration | 727 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
/>
</b-button>
</div>
</template>
</character-list>
<nft-list
v-else-if="shield"
class="nft-list"
:nftIdTypes="[{ id: shield.id, type: shield.type }]"
:showGivenNftIdTypes="true"
... | Same condition on parent `<span>` element. | v-if="!canPurchase"
v-tooltip.bottom="
'You already have max amount of characters (4).'
"
/>
</b-button>
</div>
</template>
</character-list>
<nft-list
... | @@ -46,22 +46,147 @@
:showFavoriteWeaponsDefVal="false"
:canFavorite="false"
:newWeapon="true"
- />
+ >
+ <template #above="{ weapon: { id } }">
+ <div
+ class="
+ d-flex
+ flex-column
+ ... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.214 | suggestion | 42 | 51 | 51 | false | NFT display page market integration | 727 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
</div>
</template>
</weapon-grid>
<character-list
v-else-if="character"
class="character-list"
:characterIds="[this.character.id]"
:showGivenCharacterIds="true"
:isMarket="nftPriceInSkill() !== '0'"
:n... | Same condition on parent `<span>` element. | Purchase
</b-button>
</div>
</template>
</weapon-grid>
<character-list
v-else-if="character"
class="character-list"
:characterIds="[this.character.id]"
:showGivenCharacterIds="true"
... | @@ -46,22 +46,147 @@
:showFavoriteWeaponsDefVal="false"
:canFavorite="false"
:newWeapon="true"
- />
+ >
+ <template #above="{ weapon: { id } }">
+ <div
+ class="
+ d-flex
+ flex-column
+ ... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.214 | suggestion | 42 | 51 | 51 | false | NFT display page market integration | 727 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
<div class="row result-row-section">
<weapon-grid
v-if="this.weapon"
class="weapon-grid"
:weaponIds="[this.weapon.id]"
:showGivenWeaponIds="true"
:showReforgedToggle="false"
:showReforgedWeaponsDefVal="false"
:showFavo... | Same condition on parent `<span>` element. | <div class="row result-row-section">
<weapon-grid
v-if="this.weapon"
class="weapon-grid"
:weaponIds="[this.weapon.id]"
:showGivenWeaponIds="true"
:showReforgedToggle="false"
:showReforgedWeaponsDefVal="false"
:showFavo... | @@ -46,22 +46,147 @@
:showFavoriteWeaponsDefVal="false"
:canFavorite="false"
:newWeapon="true"
- />
+ >
+ <template #above="{ weapon: { id } }">
+ <div
+ class="
+ d-flex
+ flex-column
+ ... | frontend/src/views/NftDisplay.vue | 26 | Vue | 0.214 | suggestion | 42 | 51 | 51 | false | NFT display page market integration | 727 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
<b-button
variant="primary"
@click="searchAllCharacterListings(currentPage - 1)" class="gtag-link-others" tagname="browse_characters">Browse Characters</b-button>
</div>
<div class="col">
<b-button
varian... | this should be delegated to a function, this is too much logic for a template | <b-button
variant="primary"
@click="searchAllCharacterListings(currentPage - 1)" class="gtag-link-others" tagname="browse_characters">Browse Characters</b-button>
</div>
<div class="col">
<b-button
varian... | @@ -38,7 +38,8 @@
v-visible="allSearchResults && allSearchResults.length > 0"
align="center" v-model="currentPage"
:total-rows="allListingsAmount"
- :per-page="activeType === 'weapon' ? weaponShowLimit : characterShowLimit"
+ :per-page="ac... | frontend/src/views/Market.vue | 26 | Vue | 0.286 | suggestion | 77 | 51 | 51 | false | 728-fix-shield-pagination | 729 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | bilbolPrime |
},
activeListingMarketTax(): string{
if(this.activeType === 'weapon'){
return this.weaponMarketTax;
}
if(this.activeType === 'character'){
return this.characterMarketTax;
}
if(this.activeType === 'shield'){
return this.shieldMarketTax;
}
retur... | this is more of a utility function and should be elsewhere, not here, but it's not super important | },
activeListingMarketTax(): string{
if(this.activeType === 'weapon'){
return this.weaponMarketTax;
}
if(this.activeType === 'character'){
return this.characterMarketTax;
}
if(this.activeType === 'shield'){
return this.shieldMarketTax;
}
retur... | @@ -1746,6 +1746,14 @@ export default Vue.extend({
maxPrecisionSkill(listedPrice: string): string {
return this.convertStringToDecimal(this.convertWeiToSkill(listedPrice), 8);
+ },
+
+ upperFirstChar(input: string): string { | frontend/src/views/Market.vue | 26 | Vue | 0.286 | refactor | 98 | 51 | 51 | false | 730-market-filters-broken | 731 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | bilbolPrime |
<template>
<div class="skill-balance-display">
<div size="sm" class="my-2 my-sm-0 mr-3" variant="primary" v-tooltip="'Buy SKILL'" @click="showModal">
<b-modal size="xl" class="centered-modal " ref="mass-dust-confirmation-modal" title="BUY SKILL" ok-only>
<div class="buy-skill-modal">
<div clas... | Is mass-dust-confirmation-modal copy-paste mistake? | <template>
<div class="skill-balance-display">
<div size="sm" class="my-2 my-sm-0 mr-3" variant="primary" v-tooltip="'Buy SKILL'" @click="showModal">
<b-modal size="xl" class="centered-modal " ref="transak-buy" title="BUY SKILL" ok-only>
<div class="buy-skill-modal">
<div class="buy-skill-moda... | @@ -1,6 +1,18 @@
<template>
<div class="skill-balance-display">
- <div size="sm" class="my-2 my-sm-0 mr-3" variant="primary" v-tooltip="'Buy SKILL'" @click="onBuySkill">
+ <div size="sm" class="my-2 my-sm-0 mr-3" variant="primary" v-tooltip="'Buy SKILL'" @click="showModal">
+ <b-modal size="xl" class="ce... | frontend/src/components/smart/SkillBalanceDisplay.vue | 4 | Vue | 0.214 | question | 51 | 29 | 29 | false | 490-transak-integration | 742 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | bilbolPrime |
}
.balance-text {
color : #BFA765;
}
.add-button {
width : 30px;
height: 100%;
}
.add-button:hover {
cursor: pointer;
}
.buy-skill-modal {
display: flex;
justify-content: space-between;
}
.buy-skill-modal-child{
width: 50%;
height: 300px;
align-items: center;
justify-content: space-between;
margi... | it's the same as .img-transak, so you can just do it like that:
.img-apeswap,
.img-transak {
width:100%;
max-width: 250px;
height: auto;
margin-bottom: 30px;
} | }
.balance-text {
color : #BFA765;
}
.add-button {
width : 30px;
height: 100%;
}
.add-button:hover {
cursor: pointer;
}
.buy-skill-modal {
display: flex;
justify-content: space-between;
}
.buy-skill-modal-child{
width: 50%;
height: 300px;
align-items: center;
justify-content: space-between;
margi... | @@ -170,4 +191,29 @@ export default Vue.extend({
.add-button:hover {
cursor: pointer;
}
+.buy-skill-modal {
+ display: flex;
+ justify-content: space-between;
+}
+.buy-skill-modal-child{
+ width: 50%;
+ height: 300px;
+ align-items: center;
+ justify-content: space-between;
+ margin: 10%;
+ display: flex;
... | frontend/src/components/smart/SkillBalanceDisplay.vue | 26 | Vue | 0.357 | suggestion | 175 | 39 | 33 | false | 490-transak-integration | 742 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | bilbolPrime |
function getPurchase() public view returns (uint256, uint256) {
return (purchaseAddressMapping[msg.sender].purchasedTier, purchaseAddressMapping[msg.sender].stamp);
}
function getPurchaseOf(address owner) public view returns (uint256, uint256) {
return (purchaseAddressMapping[owner].purc... | a small note on the reserve parameter, it could be a bit confusing. But since this is an admin only function it's not a big deal. Ideally the function or param name would indicate the two directions this function can set things. | return (purchaseAddressMapping[msg.sender].purchasedTier, purchaseAddressMapping[msg.sender].stamp);
}
function getPurchaseOf(address owner) public view returns (uint256, uint256) {
return (purchaseAddressMapping[owner].purchasedTier, purchaseAddressMapping[owner].stamp);
}
function g... | @@ -358,25 +430,53 @@ contract CBKLandSale is Initializable, AccessControlUpgradeable {
_enabled = allowed;
}
- function reserveChunks(uint256[] calldata chunkIds, bool reserve) external isAdmin {
+ function setReservedSaleAllowed(bool allowed) external isAdmin {
+ _reservedEnabled = allowe... | contracts/CBKLandSale.sol | 26 | Solidity | 0.5 | suggestion | 228 | 51 | 51 | false | 739-land-sale reserved sales | 800 | CryptoBlades/cryptoblades | 321 | Vue | poshdan | bilbolPrime |
uint256 counter = reservedChunksCounter[msg.sender];
for(uint256 i = counter; i < counter + rcLength; i++){
uint256 cId = reservedChunks[msg.sender].at(uint256(i % rcLength));
if(chunkT2LandSales[cId] < _allowedLandSalePerChunk) {
chunkT2LandSales[cId]++; // it's ... | is this operation missing from the two other reserve functions? Or is this mistakenly present here and neither 3 are meant to have it | uint256 counter = reservedChunksCounter[msg.sender];
for(uint256 i = counter; i < counter + rcLength; i++){
uint256 cId = reservedChunks[msg.sender].at(uint256(i % rcLength));
if(chunkT2LandSales[cId] < _allowedLandSalePerChunk) {
chunkT2LandSales[cId]++; // it's ... | @@ -217,16 +235,66 @@ contract CBKLandSale is Initializable, AccessControlUpgradeable {
cbkLand.mint(buyer, TIER_THREE, chunkId);
}
- function giveT1LandReserved(address buyer) public {
-
+ function giveT1LandReserved(address buyer) public {
+ giveT1LandReserved(buyer, '');
}
... | contracts/CBKLandSale.sol | 26 | Solidity | 0.357 | question | 133 | 51 | 51 | false | 739-land-sale reserved sales | 800 | CryptoBlades/cryptoblades | 321 | Vue | poshdan | bilbolPrime |
<span class="gtag-link-others" v-else-if="nft.type === 'claimT2Land'">
Claim Tier 2
</span>
<span class="gtag-link-others" v-else-if="nft.type === 'claimT3Land'">
Claim Tier 3
</span>
</b-button>
</li>
</ul>
<div c... | when stuff like this has multiple statements, generally it should be made into a function instead | <span class="gtag-link-others" v-else-if="nft.type === 'claimT2Land'">
Claim Tier 2
</span>
<span class="gtag-link-others" v-else-if="nft.type === 'claimT3Land'">
Claim Tier 3
</span>
</b-button>
</li>
</ul>
<div c... | @@ -74,20 +84,20 @@
<div class="centered-text-div mt-3" v-if="isSpecials && ownedLands.length !== 0">
<h4>Your owned {{ownedLands.length > 1 ? "lands" : 'land'}}:</h4>
<ul class="list-group raid-details mb-4" v-for="(land, index) in ownedLands" :key="index">
- <li class="list-group-ite... | frontend/src/components/smart/NftList.vue | 26 | Vue | 0.286 | suggestion | 97 | 51 | 51 | false | After land sale UI enhancements | 816 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Chriserus |
Claim Tier 2
</span>
<span class="gtag-link-others" v-else-if="nft.type === 'claimT3Land'">
Claim Tier 3
</span>
</b-button>
</li>
</ul>
<div class="centered-text-div mt-3" v-if="isSpecials && ownedLands.length !== 0">
... | not sure who added the style tag, but in general we should not do that, and avoid it wherever possible | Claim Tier 2
</span>
<span class="gtag-link-others" v-else-if="nft.type === 'claimT3Land'">
Claim Tier 3
</span>
</b-button>
</li>
</ul>
<div class="centered-text-div mt-3" v-if="isSpecials && ownedLands.length !== 0">
... | @@ -74,20 +84,20 @@
<div class="centered-text-div mt-3" v-if="isSpecials && ownedLands.length !== 0">
<h4>Your owned {{ownedLands.length > 1 ? "lands" : 'land'}}:</h4>
<ul class="list-group raid-details mb-4" v-for="(land, index) in ownedLands" :key="index">
- <li class="list-group-ite... | frontend/src/components/smart/NftList.vue | 26 | Vue | 0.429 | style | 102 | 51 | 51 | false | After land sale UI enhancements | 816 | CryptoBlades/cryptoblades | 321 | Vue | seiyria | Chriserus |
return IERC721ReceiverUpgradeable.onERC721Received.selector;
}
function storageIsEnabled() public view returns (bool) {
return storageEnabled;
}
function setStorageEnabled(bool enabled) public restricted {
storageEnabled = enabled;
}
// bridge stuff
function chai... | It looks like we could use `i` here instead of `index` and get rid of `index` | return IERC721ReceiverUpgradeable.onERC721Received.selector;
}
function storageIsEnabled() public view returns (bool) {
return storageEnabled;
}
function setStorageEnabled(bool enabled) public restricted {
storageEnabled = enabled;
}
// bridge stuff
function chain... | @@ -356,10 +358,27 @@ contract NFTStorage is IERC721ReceiverUpgradeable, Initializable, AccessControlU
return _bridgeEnabled[chainId];
}
+ function getEnabledChainsForBridging() public view returns (uint256[] memory chainIds) {
+ uint256 amount = _supportedChains.length();
+ chainIds =... | contracts/NFTStorage.sol | 26 | Solidity | 0.429 | suggestion | 77 | 51 | 51 | false | 781 nft bridge | 825 | CryptoBlades/cryptoblades | 321 | Vue | kcper | bilbolPrime |
const res = await NFTStorage.methods
.getNumberOfStoragedItems(nftContractAddr)
.call(defaultCallOptions(state));
return res;
},
async withdrawFromStorage({ state, dispatch }, { nftContractAddr, tokenId}: { nftContractAddr: string, tokenId: string}) {
const { NFT... | No need to have unused contracts here, please leave only the one you use | const res = await NFTStorage.methods
.getNumberOfStoragedItems(nftContractAddr)
.call(defaultCallOptions(state));
return res;
},
async withdrawFromStorage({ state, dispatch }, { nftContractAddr, tokenId}: { nftContractAddr: string, tokenId: string}) {
const { NFT... | @@ -3314,15 +3314,21 @@ export function createStore(web3: Web3) {
await dispatch('updateCharacterIds');
},
- async bridgeItem({ state }, { nftContractAddr, tokenId, targetChain}: { nftContractAddr: string, tokenId: string, targetChain: string}) {
- const { NFTStorage, Weapons, Characters... | frontend/src/store.ts | 26 | TypeScript | 0.286 | suggestion | 72 | 51 | 51 | false | 781 nft bridge | 846 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | bilbolPrime |
</span>
</b-modal>
</b-tab>
<b-tab title="Storage" @click="showStorage(); selectedNftId = ''">
<div class="d-flex flex-row justify-content-center">
<div class="p-2">
<b-button variant="primary" @click="nftType = 'weapon'; selectedNftId = ''; getStoredIds()"
... | Can we make transferStatus values as en ENUM? To have them nice and tidy | </span>
</b-modal>
</b-tab>
<b-tab title="Storage" @click="showStorage(); selectedNftId = ''">
<div class="d-flex flex-row justify-content-center">
<div class="p-2">
<b-button variant="primary" @click="nftType = 'weapon'; selectedNftId = ''; getStoredIds()"
... | @@ -56,17 +70,21 @@
</b-button>
</div>
<div class="p-2">
- <b-button :disabled="selectedNftId == '' || currentTransferNFTId == selectedNftId" variant="primary"
+ <b-button :disabled="selectedNftId === '' || currentTransferNFTId == selectedNftId" variant="primary"... | frontend/src/views/Bridge.vue | 26 | Vue | 0.214 | question | 72 | 51 | 51 | false | 781 nft bridge | 846 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | bilbolPrime |
<b-icon icon="exclamation-circle" variant="danger"/> WARNING
</template>
<span>
You will <b>not get a refund</b> of your spent SKILL fee when cancelling the transfer!<br>
</span>
</b-modal>
</b-tab>
<b-tab title="Incoming NFTs" @click="getIncoming(... | <b-button :disabled="!weaponIdToWithdraw" variant="primary" | <template #modal-title>
<b-icon icon="exclamation-circle" variant="danger"/> WARNING
</template>
<span>
You will <b>not get a refund</b> of your spent SKILL fee when cancelling the transfer!<br>
</span>
</b-modal>
</b-tab>
<b-tab title="I... | @@ -144,48 +162,60 @@
<i class="fas fa-spinner fa-spin"></i>
Loading...
</div>
+ <b-modal class="centered-modal" ref="refund-warning-modal" @ok="cancelAll()">
+ <template #modal-title>
+ <b-icon icon="exclamation-circle" variant="danger"/> WARNING
+ </te... | frontend/src/views/Bridge.vue | 26 | Vue | 0.214 | suggestion | 59 | 51 | 51 | false | 781 nft bridge | 846 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | bilbolPrime |
<option v-for="weapon in incomingWeapons"
:value="weapon['7']"
:key="weapon['3']">
Weapon ID: {{ weapon['3'] }}
from Chain: {{supportedChains[supportedChainIds.indexOf(weapon['2'])]}}
</option>
</select>
... | <b-button :disabled="!characterIdToWithdraw" variant="primary" | <option value="" disabled selected>Select your Weapon</option>
<option v-for="weapon in incomingWeapons"
:value="weapon['7']"
:key="weapon['3']">
Weapon ID: {{ weapon['3'] }}
from Chain: {{supportedChains[supportedChainI... | @@ -144,48 +162,60 @@
<i class="fas fa-spinner fa-spin"></i>
Loading...
</div>
+ <b-modal class="centered-modal" ref="refund-warning-modal" @ok="cancelAll()">
+ <template #modal-title>
+ <b-icon icon="exclamation-circle" variant="danger"/> WARNING
+ </te... | frontend/src/views/Bridge.vue | 26 | Vue | 0.214 | suggestion | 62 | 51 | 51 | false | 781 nft bridge | 846 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | bilbolPrime |
//remove currentChain from chains to send to
this.currentChain = localStorage.getItem('currentChain') || 'BSC';
this.chainsToSendTo = this.supportedChains.filter(item => item !== this.currentChain);
this.targetChain = this.chainsToSendTo[0];
//check current net by checking url
const env = wind... | .call(defaultCallOptions(state)); | : this.Shields.options.address;
},
canBridge(){
const cost = toBN(this.bridgeFee);
const balance = toBN(this.skillBalance);
return balance.isGreaterThanOrEqualTo(cost);
},
},
created(){
this.supportedChains = config.supportedChains;
//remove currentChain from chains... | @@ -347,13 +383,15 @@ export default Vue.extend({
//check current net by checking url
const env = window.location.href.startsWith('https://test') ? 'test' : 'production'; //const env = 'test';
- console.log('currentNet: ', env);
const conf = config as any;
for(let i = 0; i < this.supportedChain... | frontend/src/views/Bridge.vue | 26 | Vue | 0.071 | suggestion | 33 | 51 | 51 | false | 781 nft bridge | 846 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | bilbolPrime |
class="modal-input" v-model="recipient.address1" placeholder="Address" />
<b-form-input type="text"
class="modal-input" v-model="recipient.city" placeholder="City" />
<b-form-input type="text"
class="modal-input" v-model="recipient.zip" placeholder="Zip Code" />
<b-form-select
... | I think we're using camel case everywhere (same in the interfaces below) | class="modal-input" v-model="recipient.address1" placeholder="Address" />
<b-form-input type="text"
class="modal-input" v-model="recipient.city" placeholder="City" />
<b-form-input type="text"
class="modal-input" v-model="recipient.zip" placeholder="Zip Code" />
<b-form-select
... | @@ -49,14 +50,59 @@
<script lang="ts">
import Vue from 'vue';
import axios from 'axios';
+import { mapActions } from 'vuex';
+import { fromWeiEther } from '@/utils/common';
+import CurrencyConverter from '../../components/CurrencyConverter.vue';
+
+interface Product {
+ id: number,
+ name: string,
+ thumbnail_url... | frontend/src/components/smart/MerchandiseList.vue | 26 | Vue | 0.214 | suggestion | 72 | 51 | 51 | false | Frontend changes for merchandise purchasing #834 | 848 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Cosy0o0 |
products: Product[];
selected_product: Product | undefined;
selected_country: Country | undefined;
selected_state: string;
countries: Country[];
recipient: Recipient;
}
interface StoreMappedActions {
getItemPrice(payload: {id: number}): Promise<number>;
purchaseMerchandise(payload: {id: number, price: ... | Do we want the `recipient` to be by default populated with example data? The form input fields already have placeholders. | products: Product[];
selectedProduct: Product | undefined;
selectedCountry: Country | undefined;
countries: Country[];
states: string[];
recipient: Recipient;
}
interface StoreMappedActions {
getItemPrice(payload: {id: number}): Promise<number>;
purchaseMerchandise(payload: {id: number, price: number, ... | @@ -49,14 +50,59 @@
<script lang="ts">
import Vue from 'vue';
import axios from 'axios';
+import { mapActions } from 'vuex';
+import { fromWeiEther } from '@/utils/common';
+import CurrencyConverter from '../../components/CurrencyConverter.vue';
+
+interface Product {
+ id: number,
+ name: string,
+ thumbnail_url... | frontend/src/components/smart/MerchandiseList.vue | 26 | Vue | 0.5 | question | 121 | 51 | 51 | false | Frontend changes for merchandise purchasing #834 | 848 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Cosy0o0 |
interface StoreMappedActions {
getItemPrice(payload: {id: number}): Promise<number>;
purchaseMerchandise(payload: {id: number, price: number, amount: number}): Promise<number>;
}
export default Vue.extend({
components: {
CurrencyConverter
},
data() {
return {
products: [],
selected_produ... | Just to confirm - will `const response = await axios.get('http://localhost:2400/products');` work on all environments? | interface StoreMappedActions {
getItemPrice(payload: {id: number}): Promise<number>;
purchaseMerchandise(payload: {id: number, price: number, amount: number}): Promise<number>;
}
export default Vue.extend({
components: {
CurrencyConverter
},
data() {
return {
products: [],
selectedProduc... | @@ -78,22 +124,29 @@ export default Vue.extend({
},
methods: {
+ ...mapActions(['getItemPrice', 'purchaseMerchandise']) as StoreMappedActions,
+
async fetchProducts() {
const response = await axios.get('http://localhost:2400/products'); | frontend/src/components/smart/MerchandiseList.vue | 26 | Vue | 0.5 | question | 118 | 51 | 51 | false | Frontend changes for merchandise purchasing #834 | 848 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Cosy0o0 |
await SkillToken.methods
.approve(CryptoBlades.options.address, web3.utils.toWei('100', 'ether'))
.send({
from: state.defaultAccount
});
await Blacksmith.methods.purchaseShield().send({
from: state.defaultAccount,
gas: '500000'
});
... | Please use `approveFee` function in approval step. | await SkillToken.methods
.approve(CryptoBlades.options.address, web3.utils.toWei('100', 'ether'))
.send({
from: state.defaultAccount
});
await Blacksmith.methods.purchaseShield().send({
from: state.defaultAccount,
gas: '500000'
});
... | @@ -2663,10 +2664,33 @@ export function createStore(web3: Web3) {
]);
},
- async purchaseMerchandise({ commit }, product) {
- console.log(product, commit);
- // TODO call blockchain to purchase
- // Return a success response from the blockchain to call BE with that success va... | frontend/src/store.ts | 26 | TypeScript | 0.429 | suggestion | 50 | 51 | 51 | false | Frontend changes for merchandise purchasing #834 | 848 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Cosy0o0 |
.product-name {
text-align: center;
}
.product-grid {
list-style-type: none;
justify-content: center;
margin: 0;
display: grid;
padding: 0.5em;
grid-template-columns: repeat(auto-fit, 12em);
gap: 0.5em;
}
.product {
width: 12em;
background: rgba(255, 255, 255, 0.1);
border-radius: 5px;
cursor:... | Do we want to clear recipient after every order? That would mean users have to refill the form from scratch, correct me if I'm wrong. |
fetchStates() {
this.recipient.stateCode = undefined;
this.states = this.countries.find((country: Country) => country.code === this.recipient.countryCode)?.states || [];
},
openAddress(product: Product) {
(this.$refs['merchandise-address-modal'] as any).show();
this.selectedProduct... | @@ -132,36 +117,41 @@ export default Vue.extend({
for (const product of this.products) {
product.price = await this.getItemPrice({id: product.id});
}
- console.log(this.products);
},
async fetchCountries() {
const response = await axios.get('http://localhost:2400/countries... | frontend/src/components/smart/MerchandiseList.vue | 26 | Vue | 0.429 | bug | 133 | 51 | 51 | false | Frontend changes for merchandise purchasing #834 | 848 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Cosy0o0 |
},
updateOptions() {
if(!this.isMarket) {
this.options = [
{
name: this.$t('characterList.rename'),
amount: this.haveRename,
handler: this.openRenameCharacter
},
{
name: this.$t('characterList.changeTrait'),
... | Add translation key for 'Copy link' | },
updateOptions() {
if(!this.isMarket) {
this.options = [
{
name: this.$t('characterList.rename'),
amount: this.haveRename,
handler: this.openRenameCharacter
},
{
name: this.$t('characterList.changeTrait'),
... | @@ -332,24 +333,36 @@ export default {
},
updateOptions() {
- this.options = [
- {
- name: this.$t('characterList.rename'),
- amount: this.haveRename,
- handler: this.openRenameCharacter
- },
- {
- name: this.$t('characterList.changeTrait'),
- ... | frontend/src/components/smart/CharacterList.vue | 26 | Vue | 0.071 | suggestion | 35 | 51 | 51 | false | add copy link option to the menu for items on the market | 851 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kcper |
openChangeSkin(id: number | string) {
this.currentWeaponId = id;
(this.$refs['weapon-change-skin-modal'] as BModal).show();
},
async changeWeaponSkinCall() {
if(!this.currentWeaponId) return;
// +1 because cosmetics are 1 (not 0) based
const selectedSkinId = this.weaponCosmeti... | I know you didn't add it, but we need translation key here |
openChangeSkin(id: number | string) {
this.currentWeaponId = id;
(this.$refs['weapon-change-skin-modal'] as BModal).show();
},
async changeWeaponSkinCall() {
if(!this.currentWeaponId) return;
// +1 because cosmetics are 1 (not 0) based
const selectedSkinId = this.weaponCosmeti... | @@ -503,20 +504,32 @@ export default Vue.extend({
},
updateOptions() {
- this.options = [
- {
- name: 'Rename',
- amount: this.haveRename,
- handler: this.openRenameWeapon
- },
- {
- name: 'Change Cosmetic',
- amount: this.totalCosmeticC... | frontend/src/components/smart/WeaponGrid.vue | 26 | Vue | 0.214 | suggestion | 58 | 51 | 51 | false | add copy link option to the menu for items on the market | 851 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kcper |
hideWalletWarning: boolean;
showSkillInUsd: boolean;
}
interface StoreMappedGetters {
rewardsClaimTaxAsFactorBN: BigNumber;
maxRewardsClaimTaxAsFactorBN: BigNumber;
}
enum ClaimStage {
WaxBridge = 0,
Stake = 1,
Claim = 2
}
export default Vue.extend({
created() {
this.showGraphics = localStorage.g... | Is this necessary in user options? | hideWalletWarning: boolean;
showSkillInUsd: boolean;
}
interface StoreMappedGetters {
rewardsClaimTaxAsFactorBN: BigNumber;
maxRewardsClaimTaxAsFactorBN: BigNumber;
}
enum ClaimStage {
WaxBridge = 0,
Stake = 1,
Claim = 2
}
export default Vue.extend({
created() {
this.showGraphics = localStorage.g... | @@ -130,12 +130,11 @@ export default Vue.extend({
this.hideRewards = localStorage.getItem('hideRewards') === 'true';
this.hideWalletWarning = localStorage.getItem('hideWalletWarning') === 'true';
this.showSkillInUsd = localStorage.getItem('showSkillInUsd') === 'true';
- this.isBridgeEnabled = bridgeEn... | frontend/src/components/Options.vue | 26 | Vue | 0.143 | question | 34 | 51 | 51 | false | Add Merchandise feature flag | 902 | CryptoBlades/cryptoblades | 321 | Vue | Sellie96 | Chriserus |
bool isPending;
}
struct BountyDistribution {
uint256 winnerReward;
uint256 loserPayment;
uint256 rankingPoolTax;
}
bytes32 public constant GAME_ADMIN = keccak256("GAME_ADMIN");
CryptoBlades public game;
Characters public characters;
Weapons public weapons;... | you cannot change the order of state variables. New ones have to be added after all the others | bool isPending;
}
struct BountyDistribution {
uint256 winnerReward;
uint256 loserPayment;
uint256 rankingPoolTax;
}
bytes32 public constant GAME_ADMIN = keccak256("GAME_ADMIN");
CryptoBlades public game;
Characters public characters;
Weapons public weapons;... | @@ -57,6 +57,8 @@ contract PvpArena is Initializable, AccessControlUpgradeable {
uint8 public wageringFactor;
/// @dev percentage of duel cost charged when rerolling opponent
uint256 public reRollFeePercent;
+ /// @dev percentage of entry wager charged when withdrawing from arena with pending duel
+ ... | contracts/PvpArena.sol | 26 | Solidity | 0.286 | suggestion | 94 | 51 | 51 | false | Fix/pvp fixes | 922 | CryptoBlades/cryptoblades | 321 | Vue | poshdan | Jcalcaldev |
methods: {
async leaveArena() {
this.loading = true;
try {
await this.contracts().PvpArena.methods.withdrawFromArena(this.currentCharacterId).send({ from: this.defaultAccount });
this.$emit('leaveArena');
} catch (err) {
console.log('leave arena error: ', err);
}... | I would extract it to a variable, would just look nice and be more readable (totally optional, your call) | handleErrorMessage(value, errorMessage, returnedMessage) {
if (value.includes(`reverted with reason string '${errorMessage}'`)) {
return this.$dialog.notify.error(returnedMessage);
}
return 'There has been an error. Try again.';
},
async leaveArena() {
this.loading = true;
... | @@ -278,30 +283,49 @@ export default {
this.$emit('leaveArena');
} catch (err) {
- console.log('leave arena error: ', err);
+ console.log('leave arena error: ', err.message);
+
+ this.handleErrorMessage(err.message, 'Char not in arena', 'The character is not in the arena');
+ ... | frontend/src/components/smart/PvPArenaMatchMaking.vue | 26 | Vue | 0.429 | refactor | 105 | 51 | 51 | false | Feat/pvp overhaul frontend | 978 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | RafaelVidaurre |
console.log('leave arena error: ', err);
}
this.loading = false;
},
async findMatch() {
this.loading = true;
try {
await this.contracts().PvpArena.methods.requestOpponent(this.currentCharacterId).send({ from: this.defaultAccount });
} catch (err) {
consol... | Do we want to leave the console log here? Maybe the next lines are sufficient. Also, if it's an error, please use console.error() | try {
await this.contracts().PvpArena.methods.withdrawFromArena(this.currentCharacterId).send({ from: this.defaultAccount });
this.$emit('leaveArena');
} catch (err) {
console.log('leave arena error: ', err.message);
this.handleErrorMessage(err.message, 'Char not in arena',... | @@ -278,30 +283,49 @@ export default {
this.$emit('leaveArena');
} catch (err) {
- console.log('leave arena error: ', err);
+ console.log('leave arena error: ', err.message);
+
+ this.handleErrorMessage(err.message, 'Char not in arena', 'The character is not in the arena');
+ ... | frontend/src/components/smart/PvPArenaMatchMaking.vue | 26 | Vue | 0.571 | question | 129 | 51 | 51 | false | Feat/pvp overhaul frontend | 978 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | RafaelVidaurre |
this.duel = await this.contracts().PvpArena.methods.duelByAttacker(this.currentCharacterId).call();
this.loading = false;
},
async reRollOpponent() {
this.loading = true;
try {
await this.contracts().SkillToken.methods
.approve(this.contracts().PvpArena.options.addre... | Same here, just to make it readable, extract it (optional) | }
this.loading = true;
try {
await this.contracts().PvpArena.methods.findOpponent(this.currentCharacterId).send({ from: this.defaultAccount });
} catch (err) {
console.log('find match error: ', err.message);
this.handleErrorMessage(err.message, 'No enemy found', 'No op... | @@ -278,30 +283,49 @@ export default {
this.$emit('leaveArena');
} catch (err) {
- console.log('leave arena error: ', err);
+ console.log('leave arena error: ', err.message);
+
+ this.handleErrorMessage(err.message, 'Char not in arena', 'The character is not in the arena');
+ ... | frontend/src/components/smart/PvPArenaMatchMaking.vue | 26 | Vue | 0.286 | refactor | 58 | 51 | 51 | false | Feat/pvp overhaul frontend | 978 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | RafaelVidaurre |
} catch (err) {
console.log('reroll opponent error: ', err);
this.loading = false;
return;
}
this.duel = await this.contracts().PvpArena.methods.duelByAttacker(this.currentCharacterId).call();
this.loading = false;
},
async listenForDuel(contracts) {
co... | Same here (console.error, or delete it) | this.handleErrorMessage(err.message, 'Char not in arena', 'The character is not in the arena.');
this.loading = false;
return;
}
this.match = await this.contracts().PvpArena.methods.matchByFinder(this.currentCharacterId).call();
this.loading = false;
},
async reRoll... | @@ -310,14 +334,19 @@ export default {
await this.contracts().PvpArena.methods.reRollOpponent(this.currentCharacterId).send({ from: this.defaultAccount });
} catch (err) {
- console.log('reroll opponent error: ', err);
+ console.log('reroll opponent error: ', err.message); | frontend/src/components/smart/PvPArenaMatchMaking.vue | 26 | Vue | 0.214 | suggestion | 39 | 51 | 51 | false | Feat/pvp overhaul frontend | 978 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | RafaelVidaurre |
.enterArena(this.currentCharacterId, this.selectedWeaponId, shieldId, isUsingShield)
.send({
from: this.defaultAccount
});
} catch(err){
console.log('Enter Arena Error: ', err);
return;
}
this.$emit('enteredArena');
} el... | Console logs, probably delete it | .approve(this.contracts().PvpArena.options.address, this.entryWager)
.send({
from: this.defaultAccount
});
} catch(err) {
console.log('Enter Arena Approval Error: ', err);
this.handleErrorMessage();
return;
}
try {
... | @@ -295,6 +307,7 @@ export default {
console.log(this.entryWager);
console.log('Missing data'); | frontend/src/components/smart/PvPArenaPreparation.vue | 26 | Vue | 0.071 | suggestion | 32 | 51 | 51 | false | Feat/pvp overhaul frontend | 978 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | RafaelVidaurre |
from: this.defaultAccount
});
} catch(err){
console.log('Enter Arena Error: ', err);
return;
}
this.$emit('enteredArena');
} else {
console.log(this.currentCharacterId);
console.log(this.selectedWeaponId);
console.log(th... | With all the loadings and such, if there is a try catch and after that some loading is set to false regardless of the outcome -> I would put it in finally. Maybe not this particular place ofc | from: this.defaultAccount
});
} catch(err) {
console.log('Enter Arena Approval Error: ', err);
this.handleErrorMessage();
return;
}
try {
await this.contracts().PvpArena.methods
.enterArena(this.currentCharacterId, thi... | @@ -295,6 +307,7 @@ export default {
console.log(this.entryWager);
console.log('Missing data');
}
+ this.loading = false; | frontend/src/components/smart/PvPArenaPreparation.vue | 26 | Vue | 0.357 | suggestion | 191 | 51 | 51 | false | Feat/pvp overhaul frontend | 978 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | RafaelVidaurre |
<template>
<div @click="close" class="modalWrapper">
<div class="modalInnerWrapper">
<img src="../../assets/separatorTop.svg" alt="Top separator">
<div v-if="attackerRoll > defenderRoll" class="modalTitle">You have won the duel!</div>
<div v-else class="modalTitle"> You have lost the duel!</div>... | I noticed there are many places without translations. Is it planned to add them later? Just take note, that we should use i18n now | <template>
<div @click="close" class="modalWrapper">
<div class="modalInnerWrapper">
<img src="../../assets/separatorTop.svg" alt="Top separator">
<div v-if="attackerRoll > defenderRoll" class="modalTitle">You have won the duel!</div>
<div v-else class="modalTitle"> You have lost the duel!</div>... | @@ -6,7 +6,7 @@
<div v-else class="modalTitle"> You have lost the duel!</div>
<ul>
<li>
- <span>You Rolled</span>
+ <span>You rolled</span> | frontend/src/components/smart/PvPDuelModal.vue | 9 | Vue | 0.429 | suggestion | 130 | 34 | 34 | false | Feat/pvp overhaul frontend | 978 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | RafaelVidaurre |
</button>
</div>
</div>
<div class="stakePage medium-dark-bg">
<div class="sPElement input overflow">
<div class="inputBody overflow">
<div :class="isNftStaking ? 'd-flex align-items-center w-100 overflow' : 'flex_row'">
<input
v-... | small thing, space missing:
isDeposit ? ownedLandIds : stakedIds | </button>
</div>
</div>
<div class="stakePage medium-dark-bg">
<div class="sPElement input overflow">
<div class="inputBody overflow">
<div :class="isNftStaking ? 'd-flex align-items-center w-100 overflow' : 'flex_row'">
<input
v-... | @@ -63,17 +63,16 @@
value=""
v-model="textAmount"
/>
- <div v-if="isNftStaking" class="mr-2 ml-3">ID:</div>
- <b-form-select
- class="w-100"
- v-if="isNftStaking"
- :title="$t('stake.tokenAmount')"
- ... | frontend/src/components/smart/Staking.vue | 26 | Vue | 0.214 | suggestion | 65 | 51 | 51 | false | bulk staking | 979 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kcper |
<div class="inputBody overflow">
<div :class="isNftStaking ? 'd-flex align-items-center w-100 overflow' : 'flex_row'">
<input
v-if="!isNftStaking"
class="token-amount-input"
inputmode="decimal"
:title="$t('stake.tokenAmo... | Missing translation, IDs selected | <div class="inputBody overflow">
<div :class="isNftStaking ? 'd-flex align-items-center w-100 overflow' : 'flex_row'">
<input
v-if="!isNftStaking"
class="token-amount-input"
inputmode="decimal"
:title="$t('stake.tokenAmo... | @@ -63,17 +63,16 @@
value=""
v-model="textAmount"
/>
- <div v-if="isNftStaking" class="mr-2 ml-3">ID:</div>
- <b-form-select
- class="w-100"
- v-if="isNftStaking"
- :title="$t('stake.tokenAmount')"
- ... | frontend/src/components/smart/Staking.vue | 26 | Vue | 0.071 | suggestion | 33 | 51 | 51 | false | bulk staking | 979 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kcper |
currentRewardEarned,
rewardMinimumStakeTime: parseInt(rewardMinimumStakeTime, 10),
rewardDistributionTimeLeft: parseInt(rewardDistributionTimeLeft, 10),
unlockTimeLeft: parseInt(unlockTimeLeft, 10)
};
commit('updateStakeData', stakeData);
},
async sta... | I think it should have state.defaultAccount check, but not sure, we'll have to look into other methods. | currentRewardEarned,
rewardMinimumStakeTime: parseInt(rewardMinimumStakeTime, 10),
rewardDistributionTimeLeft: parseInt(rewardDistributionTimeLeft, 10),
unlockTimeLeft: parseInt(unlockTimeLeft, 10)
};
commit('updateStakeData', stakeData);
},
async sta... | @@ -2214,6 +2214,48 @@ export function createStore(web3: Web3) {
await dispatch('fetchStakeDetails', { stakeType });
},
+ async stakeNfts({ state, dispatch }, { ids, stakeType }: { ids: string[], stakeType: StakeType }) {
+ const { StakingRewards, StakingToken } = getStakingContracts(state... | frontend/src/store.ts | 26 | TypeScript | 0.429 | suggestion | 103 | 51 | 51 | false | bulk staking | 979 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kcper |
ttHtml += `<br>${wrapInSpan(this.nft.stat2, this.nft.stat2)}: +${this.nft.stat2Value}`;
if(this.currentCharacter) {
ttHtml += ` (${wrapInSpanTextOnly(
this.currentCharacter.traitName,
'+'+Stat2PercentForChar(this.nft, +this.currentCharacter.trait)+'%')
})`;
... | AVG could use a translation key :D | ttHtml += `<br>${wrapInSpan(this.nft.stat2, this.nft.stat2)}: +${this.nft.stat2Value}`;
if(this.currentCharacter) {
ttHtml += ` (${wrapInSpanTextOnly(
this.currentCharacter.traitName,
'+'+Stat2PercentForChar(this.nft, +this.currentCharacter.trait)+'%')
})`;
... | @@ -230,6 +234,14 @@ export default {
}
}
+ if(avg.length > 0) {
+ let totalStats = 0;
+ avg.forEach(function (stat) {
+ totalStats += stat;
+ });
+ ttHtml += `<br>AVG: +${ totalStats / avg.length }`; | frontend/src/components/NftIcon.vue | 26 | Vue | 0.143 | suggestion | 34 | 51 | 51 | false | Avg weapon stat | 1,004 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | Sellie96 |
<template>
<div>
<div class="mainWrapper" @click="$emit('click')">
<div class="starsWrapper">
<img
v-for="index in stars"
:key="index"
src="../../assets/star.svg"
alt="star"
/>
</div>
<div class="weaponWrapper">
<img :src="getWeapon... | Weird indents here, but we can fix it later | margin-right: auto;
left: 0;
right: 0;
bottom: -25%;
padding: 0.2rem;
border: 1px solid #cec198;
border-radius: 9999px;
background-color: #151515;
img {
max-width: 100%;
max-height: 100%;
}
}
.weapon-icon {
height: 100%;
width: 100%;
position: relative;
overflow: hidden;
}
.weapon-i... | @@ -127,4 +171,31 @@ export default {
max-height: 100%;
}
}
+.weapon-icon {
+ height: 100%;
+ width: 100%;
+ position: relative;
+ overflow: hidden;
+}
+.weapon-icon-wrapper {
+ font-family: 'Roboto';
+ width: max-content;
+ margin: 0 auto;
+ padding: 0;
+ .statsWrapper { | frontend/src/components/smart/PvPWeapon.vue | 26 | Vue | 0.071 | style | 43 | 130 | 42 | false | Feat/pvp weapons info | 1,011 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | Jcalcaldev |
const t2Land = res[1];
const t3Land = res[2];
return { t1Land, t2Land, t3Land };
},
async getReservedChunksIds({state}) {
const CBKLandSale = state.contracts().CBKLandSale!;
return await CBKLandSale.methods
.getReservedChunksIds()
.call(defaultC... | Either use non-null assertion operator (**!**) on Promos or check if(!Promos), they both serve the same purpsoe here. | const t2Land = res[1];
const t3Land = res[2];
return { t1Land, t2Land, t3Land };
},
async getReservedChunksIds({state}) {
const CBKLandSale = state.contracts().CBKLandSale!;
return await CBKLandSale.methods
.getReservedChunksIds()
.call(defaultC... | @@ -2649,6 +2649,17 @@ export function createStore(web3: Web3) {
.call(defaultCallOptions(state));
},
+ async isShieldPurchased({state}) {
+ const Promos = state.contracts().Promos!;
+ if (!state.defaultAccount || !Promos) return; | frontend/src/store.ts | 26 | TypeScript | 0.571 | suggestion | 117 | 51 | 51 | false | Add frontend lockout to additional shield purchases | 1,017 | CryptoBlades/cryptoblades | 321 | Vue | kcper | krisukox |
'rewardsDuration',
'deprecated',
'rewardDistributionTimeLeft'
],
computed: {
minimumStakeTimeFormatted() {
return formatDurationFromSeconds(this.minimumStakeTime);
},
isNftStaking() {
return isNftStakeType(this.stakeType);
},
rewardsDurationFormatted() {
return form... | Please use i18n translations. Check readme on how to use it or look into other components that have translations | 'rewardsDuration',
'deprecated',
'rewardDistributionTimeLeft'
],
computed: {
minimumStakeTimeFormatted() {
return formatDurationFromSeconds(this.minimumStakeTime);
},
isNftStaking() {
return isNftStakeType(this.stakeType);
},
rewardsDurationFormatted() {
return form... | @@ -77,8 +92,23 @@ export default {
},
rewardsDurationFormatted() {
return formatDurationFromSeconds(this.rewardsDuration);
- }
- }
+ },
+ },
+ methods: {
+ getExclamationMark(rewardDistributionTimeLeft) {
+ if(rewardDistributionTimeLeft > 0) {
+ return 'green-exclamation-mark';... | frontend/src/components/StakeSelectorItem.vue | 26 | Vue | 0.429 | suggestion | 112 | 51 | 51 | false | Add exclamation mark to indicate rewards in staking pool | 1,036 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | krisukox |
toggleShowSkillInUsd() {
this.showSkillInUsd = !this.showSkillInUsd;
if (this.showSkillInUsd) localStorage.setItem('showSkillInUsd', 'true');
else localStorage.setItem('showSkillInUsd', 'false');
Events.$emit('setting:showSkillInUsd', { value: this.showSkillInUsd });
},
toggleShowC... | There's a router being used in common.ts without `as any` conversion. You could create and export a function in common.ts that will do `router.replace` and call it from here. |
toggleShowSkillInUsd() {
this.showSkillInUsd = !this.showSkillInUsd;
if (this.showSkillInUsd) localStorage.setItem('showSkillInUsd', 'true');
else localStorage.setItem('showSkillInUsd', 'false');
Events.$emit('setting:showSkillInUsd', { value: this.showSkillInUsd });
},
toggleShow... | @@ -303,6 +303,12 @@ export default Vue.extend({
async setCurrentChain() {
localStorage.setItem('currentChain', this.currentChain);
Events.$emit('setting:currentChain', { value: this.currentChain });
+ (this as any).$router.replace( | frontend/src/views/Options.vue | 26 | Vue | 0.571 | suggestion | 175 | 51 | 51 | false | resolves #1031 | 1,040 | CryptoBlades/cryptoblades | 321 | Vue | kcper | kevinunger |
</li>
<li>
<span>2</span>
<span>{{tierTopRankers[1] && tierTopRankers[1].name ||'-'}}</span>
<span>{{tierTopRankers[1] && tierTopRankers[1].level ||'-'}}</span>
<span>{{tierTopRankers[1] && tierTopRankers[1].element ||'-'}}</span>
<span>{{tierTopRankers[... | Is this needed? I don't see it being used anywhere, but I might be wrong | </li>
<li>
<span>2</span>
<span>{{tierTopRankers[1] && tierTopRankers[1].name ||'-'}}</span>
<span>{{tierTopRankers[1] && tierTopRankers[1].level ||'-'}}</span>
<span>{{tierTopRankers[1] && tierTopRankers[1].element ||'-'}}</span>
<span>{{tierTopRankers[... | @@ -1,92 +1,108 @@
<template>
<div class="leaderboardWrapper">
- <span>Leaderboards coming soon!</span>
- <!-- <h1 class="leaderboardTitle">ARENA LEADERBOARD</h1>
+ <h1 class="leaderboardTitle">{{$t("pvp.leaderboard").toUpperCase()}}</h1>
<div class="filtersWrapper">
<div class="selectWrapper">... | frontend/src/components/smart/PvPLeaderboards.vue | 26 | Vue | 0.286 | bug | 72 | 51 | 51 | false | Feat/pvp misc and leaderboards | 1,048 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | Dvidaurre |
<script>
import { getCharacterNameFromSeed } from '../../character-name';
import { characterFromContract as formatCharacter } from '../../contract-models';
import { mapState, mapActions } from 'vuex';
export default {
inject: ['web3'],
data() {
return {
tierTopRankers: [],
tierFilterOptions: [
... | defaultAccount is probably not used anymore | <script>
import { getCharacterNameFromSeed } from '../../character-name';
import { characterFromContract as formatCharacter } from '../../contract-models';
import { mapState, mapActions } from 'vuex';
export default {
data() {
return {
tierTopRankers: [],
tierFilterOptions: [
{ text: '1', valu... | @@ -1,92 +1,108 @@
<template>
<div class="leaderboardWrapper">
- <span>Leaderboards coming soon!</span>
- <!-- <h1 class="leaderboardTitle">ARENA LEADERBOARD</h1>
+ <h1 class="leaderboardTitle">{{$t("pvp.leaderboard").toUpperCase()}}</h1>
<div class="filtersWrapper">
<div class="selectWrapper">... | frontend/src/components/smart/PvPLeaderboards.vue | 26 | Vue | 0.143 | suggestion | 43 | 51 | 51 | false | Feat/pvp misc and leaderboards | 1,048 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | Dvidaurre |
}
state.cartEntries.push(cartEntry);
},
removeCartEntry(state: IState, cartEntry: CartEntry) {
state.cartEntries.splice(state.cartEntries.indexOf(cartEntry), 1);
},
clearCartEntries(state: IState) {
state.cartEntries = [];
},
updateCurrentChainSuppo... | I think you can use getConfigValue here, can't you? | state.cartEntries.push(cartEntry);
},
removeCartEntry(state: IState, cartEntry: CartEntry) {
state.cartEntries.splice(state.cartEntries.indexOf(cartEntry), 1);
},
clearCartEntries(state: IState) {
state.cartEntries = [];
},
updateCurrentChainSupportsMerchan... | @@ -743,12 +748,23 @@ export function createStore(web3: Web3) {
updateCurrentChainSupportsMerchandise(state: IState) {
const currentChain = localStorage.getItem('currentChain') || 'BSC';
const merchandiseSupportedChains = config.merchandiseSupportedChains;
+ console.log(merchandiseSuppor... | frontend/src/store.ts | 26 | TypeScript | 0.286 | question | 51 | 51 | 51 | false | Add PvP chain support checks, adjust merchandise chain check | 1,053 | CryptoBlades/cryptoblades | 321 | Vue | kcper | Chriserus |
return entryWager;
},
async getIsWeaponInArena({ state }, weaponId) {
const { PvpArena } = state.contracts();
if (!PvpArena || !state.defaultAccount) return;
const isWeaponInArena = await PvpArena.methods.isWeaponInArena(weaponId).call({ from: state.defaultAccount });
... | Delete unnecessary console logs |
return entryWager;
},
async getIsWeaponInArena({ state }, weaponId) {
const { PvpArena } = state.contracts();
if (!PvpArena || !state.defaultAccount) return;
const isWeaponInArena = await PvpArena.methods.isWeaponInArena(weaponId).call({ from: state.defaultAccount });
... | @@ -4334,9 +4356,10 @@ export function createStore(web3: Web3) {
async getIsCharacterInArena({ state, commit }, characterId) {
const { PvpArena } = state.contracts();
if (!PvpArena || !state.defaultAccount) return;
-
+ console.log('fetching'); | frontend/src/store.ts | 26 | TypeScript | 0.071 | suggestion | 31 | 51 | 51 | false | Garrison xp | 1,088 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kcper |
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "abdk-libraries-solidity/ABDKMath64x64.sol";
library Common {
using ABDKMath64x64 for int128;
using SafeMath for uint256;
using SafeMath for uint8;
function isTraitEffectiveAgainst(uint8 attacker, uint8 defender) inter... | recursive call. I think you copied the code from characters | pragma solidity ^0.6.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "abdk-libraries-solidity/ABDKMath64x64.sol";
library Common {
using ABDKMath64x64 for int128;
using SafeMath for uint256;
using SafeMath for uint8;
function isTraitEffectiveAgainst(uint8 attacker, uint8 defender) inter... | @@ -18,4 +19,20 @@ library Common {
) internal pure returns(uint24) {
return uint24(weaponMultiplier.mulu(basePower).add(bonusPower));
}
-}
\ No newline at end of file
+
+ function getPowerAtLevel(uint8 level) internal pure returns (uint24) {
+ return Common.getPowerAtLevel(level); | contracts/common.sol | 24 | Solidity | 0.214 | suggestion | 59 | 39 | 38 | false | Add getPowerAtLevel() to common.sol | 1,106 | CryptoBlades/cryptoblades | 321 | Vue | poshdan | brian-man |
<div class="outcome" v-if="transferingToStorage">
<i class="fas fa-spinner fa-spin"></i>
{{$t('bridge.loading')}}
</div>
<b-modal class="centered-modal" ref="character-warning-modal" @ok="transferToStorage()">
<template #modal-title class="text-capitalize">
... | I would extract the @click to a method, as it has 3 actions going on here | <i class="fas fa-spinner fa-spin"></i>
{{$t('bridge.loading')}}
</div>
<b-modal class="centered-modal" ref="character-warning-modal" @ok="transferToStorage()">
<template #modal-title class="text-capitalize">
<b-icon class="mr-2" icon="exclamation-circle" variant=... | @@ -74,9 +87,13 @@
</b-button>
</div>
<div class="p-2">
- <b-button :disabled="selectedNftId === '' ||
- (currentTransferNFTId === selectedNftId && transferStatus !== transferStates.restored) ||
- !storedNftsIds.includes(String(selectedNftId))"
+ ... | frontend/src/views/Bridge.vue | 26 | Vue | 0.286 | refactor | 73 | 51 | 51 | false | added shields for bridging | 1,109 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
<div v-if="nftType === 'weapon' && storedNftsIds.length !== 0">
<weapon-grid
v-model="selectedNftId"
:showReforgedWeaponsDefVal="true"
:showFavoriteWeaponsDefVal="true"
:showReforgedToggle="true"
:showFavoriteToggle="true"
:canFavorite="false... | Can you please check again if we need all of these attributes? We're showing shields here, but we're including :characterIds and we are using nftDisplay flag, is this needed? | <weapon-grid
v-model="selectedNftId"
:showReforgedWeaponsDefVal="true"
:showFavoriteWeaponsDefVal="true"
:showReforgedToggle="true"
:showFavoriteToggle="true"
:canFavorite="false"
:weaponIds="storedNftsIds"
:showGivenWeaponIds="tr... | @@ -165,6 +190,20 @@
<div v-else-if="nftType === 'character'">
<h3 class="text-center p-4">{{$t('bridge.noCharactersStored')}}</h3>
</div>
+ <div v-if="nftType === 'shield' && storedNftsIds.length !== 0">
+ <nft-list
+ v-model="selectedNftId"
+ :characterId... | frontend/src/views/Bridge.vue | 26 | Vue | 0.357 | question | 174 | 51 | 51 | false | added shields for bridging | 1,109 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
:value="weapon['7']"
:key="weapon['3']">
{{$t('bridge.weaponId')}}: {{ weapon['3'] }}
{{$t('bridge.fromChain')}}: {{supportedChains[supportedChainIds.indexOf(weapon['2'])]}}
</option>
</select>
<div class="mt... | Missing translations in this div | </option>
</select>
<div class="mt-2 text-center">
<b-button :disabled="!weaponIdToWithdraw" variant="primary" @click="withdrawBridge(weaponIdToWithdraw)"
class="gtag-link-others withdrawBtn" tagname="click_transfer_bridge"> {{ $t('br... | @@ -210,12 +249,29 @@
{{supportedChains[supportedChainIds.indexOf(character['2'])]}}
</option>
</select>
- <div class="p-2 text-center">
+ <div class="mt-2 text-center">
<b-button :disabled="!characterIdToWithdraw" variant="pr... | frontend/src/views/Bridge.vue | 26 | Vue | 0.071 | suggestion | 32 | 51 | 51 | false | added shields for bridging | 1,109 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
</b-tab>
<b-tab :title="$t('bridge.incomingNfts')" @click="getIncoming(); selectedNftId = ''">
<div v-if="incomingNftIds.length === 0">
<h3 class="text-center p-4">{{$t('bridge.noIncomingNfts')}}</h3>
</div>
<div v-else>
<div class="d-flex flex-row flex-wrap bd-hi... | If there was enough time for that, I would refactor the way we are handling types in a bridge, character should be a type here, we should access a particular attribute, not access it via '7', similar in other places in code here | </div>
<div v-else>
<div class="d-flex flex-row flex-wrap bd-highlight mb-3 justify-content-center">
<div v-if="incomingWeapons.length !== 0" class="p-4 w-20">
<h4 class="text-center withdrawText">{{$t('bridge.selectWeaponToWithdraw')}}</h4>
<select clas... | @@ -193,15 +232,15 @@
{{$t('bridge.fromChain')}}: {{supportedChains[supportedChainIds.indexOf(weapon['2'])]}}
</option>
</select>
- <div class="p-2 text-center">
+ <div class="mt-2 text-center">
<b-button :disabled="!weaponIdT... | frontend/src/views/Bridge.vue | 26 | Vue | 0.643 | refactor | 228 | 51 | 51 | false | added shields for bridging | 1,109 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
<style scoped>
.btnRow{
flex-wrap: wrap;
}
.btn{
line-height: 1.25em;
height: 4em;
white-space:nowrap;
}
.outcome {
margin: 20px auto;
text-align: center;
font-size: 1em;
}
/deep/ .character-list{
justify-content: center;
}
/deep/ .weapon-grid{
grid-template-columns: repeat(auto-fit,12em);
box-shadow... | If you want extra-clean css, you can add it like that:
.withdrawSelect{
margin:0 auto;
}
.withdrawSelect,
.withdrawBtn{
width:clamp(200px, 20vw , 300px);
} | .btn{
line-height: 1.25em;
height: 4em;
white-space:nowrap;
}
.outcome {
margin: 20px auto;
text-align: center;
font-size: 1em;
}
/deep/ .character-list{
justify-content: center;
}
/deep/ .weapon-grid{
grid-template-columns: repeat(auto-fit,12em);
box-shadow: 0 0 0 0 rgba(0, 0, 0, 1);
transform: scale... | @@ -622,4 +708,14 @@ export default Vue.extend({
box-shadow: 0 0 0 0 rgba(0, 0, 0, 1);
transform: scale(1);
}
+.withdrawText{
+ font-size: clamp(12px, 1.25rem, 24px);
+}
+.withdrawSelect{
+ width: clamp(200px, 20vw, 300px);
+ margin:0 auto;
+}
+.withdrawBtn{ | frontend/src/views/Bridge.vue | 26 | Vue | 0.357 | suggestion | 168 | 34 | 30 | false | added shields for bridging | 1,109 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
this.refreshIntervall = window.setInterval(async () => await this.showStorage(), 5000);
},
beforeDestroy(){
clearInterval(this.refreshIntervall);
},
methods: {
...(mapActions([
'fetchShields',
'fetchWeapons',
'fetchCharacters',
'storeItem',
'getStorageItemIds',
'g... | I'll look into it a bit, but maybe it's possible to map the ids if they are different? Also, that's bridge-specific, right? Bcs I'm using fetching weapons/junk/shields and all that by ids and it's all done in a similar manner, not some kind of type.id. I'll look into it and come back to you | },
methods: {
...(mapActions([
'fetchShields',
'fetchWeapons',
'fetchCharacters',
'storeItem',
'getStorageItemIds',
'getNumberOfStoragedItems',
'withdrawFromStorage',
'getNFTChainId',
'bridgeItem',
'getBridgeTransfer',
'getBridgeTransferId',
... | @@ -451,6 +524,9 @@ export default Vue.extend({
return fromWeiEther(wei);
},
async transferToStorage(){
+ // chars & weapon ids are ints; other nfts are <type.id>
+ if(this.nftType !== 'weapon' && this.nftType !== 'character') this.selectedNftId = this.selectedNftId.split('.')[1]; | frontend/src/views/Bridge.vue | 26 | Vue | 0.571 | suggestion | 291 | 51 | 51 | false | added shields for bridging | 1,109 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
/// @dev if defender is in a duel that has not finished processing
mapping(uint256 => bool) public isDefending;
/// @dev if a character is someone else's opponent
mapping(uint256 => uint256) public finderByOpponent;
/// @dev character's tier when it last entered arena. Used to reset rank if it chang... | the new mapping must come after the last state variable, please correct | /// @dev if defender is in a duel that has not finished processing
mapping(uint256 => bool) public isDefending;
/// @dev if a character is someone else's opponent
mapping(uint256 => uint256) public finderByOpponent;
/// @dev character's tier when it last entered arena. Used to reset rank if it chang... | @@ -118,6 +118,8 @@ contract PvpArena is Initializable, AccessControlUpgradeable {
uint256 public duelOffsetCost;
address payable public pvpBotAddress;
+ /// @dev owner's address by character ID
+ mapping(uint256 => address) private _ownerByCharacter;
mapping(uint256 => uint256) public specialWea... | contracts/PvpArena.sol | 26 | Solidity | 0.214 | suggestion | 71 | 51 | 51 | false | Feat/pvp ranked rewards on burnt chars | 1,120 | CryptoBlades/cryptoblades | 321 | Vue | poshdan | Jcalcaldev |
export interface Nft {
id: number | string;
type?: string;
stars?: number;
element?: string;
stat1Type?: number;
stat2Type?: number;
stat3Type?: number;
stat1?: string;
stat2?: string;
stat3?: string;
stat1Value?: number;
stat2Value?: number;
stat3Value?: number;
nftPrice?: number;
amount?... | A really minor thing, interfaces should be kept in Pascal case, so, TransferedNft and NftTransfer :) | export interface Nft {
id: number | string;
type?: string;
stars?: number;
element?: string;
stat1Type?: number;
stat2Type?: number;
stat3Type?: number;
stat1?: string;
stat2?: string;
stat3?: string;
stat1Value?: number;
stat2Value?: number;
stat3Value?: number;
nftPrice?: number;
amount?... | @@ -23,6 +23,26 @@ export type NftType = 'weapon' | 'character' | 'shield';
export const allNftTypes: NftType[] = ['weapon', 'character', 'shield'];
+export interface transferedNft { | frontend/src/interfaces/Nft.ts | 26 | TypeScript | 0.429 | suggestion | 100 | 49 | 49 | false | issue-1080-additional-changes | 1,121 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
validator(type) {
return isNftType(type);
},
},
nftIdProp: {
type: String,
},
},
data() {
return {
weapon: null as Nft | null,
character: null as Nft | null,
shield: null as Nft | null,
ownerAddress: '',
nftType: 'weapon',
selectedNftId:... | We should usually use `undefined` as a "no value", this way, in interfaces, when you declare the field that can be either a number or a "no value", you can use
`currentTransferNFTId?: number`, this way it's optional.
But it's nothing to worry about, just a tip | validator(type) {
return isNftType(type);
},
},
nftIdProp: {
type: String,
},
},
data() {
return {
weapon: null as Nft | null,
character: null as Nft | null,
shield: null as Nft | null,
ownerAddress: '',
nftType: 'weapon',
selectedNftId:... | @@ -373,19 +375,19 @@ export default Vue.extend({
storedNftsIds: [] as string[],
currentChain: '',
targetChain: '',
- targetChainId: '',
+ targetChainId: 0 as number | null,
supportedChains: [] as string[],
- supportedChainIds: [] as string[],
+ supportedChainIds: [] as n... | frontend/src/views/Bridge.vue | 26 | Vue | 0.786 | suggestion | 265 | 51 | 51 | false | issue-1080-additional-changes | 1,121 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
return;
}
if(transfer.status === 1){
this.transferStatus = transferStates.pending;
}
else if(transfer.status === 2){
this.transferStatus = transferStates.processing;
}
else if(transfer.status === 3){
this.transferStatus = transferStates.done;
}
... | Console.table to delete I guess :D | return;
}
if(transfer.status === 1){
this.transferStatus = transferStates.pending;
}
else if(transfer.status === 2){
this.transferStatus = transferStates.processing;
}
else if(transfer.status === 3){
this.transferStatus = transferStates.done;
}
... | @@ -583,56 +596,58 @@ export default Vue.extend({
this.incomingNftIds = await this.getReceivedNFTs();
for(let i = 0; i < this.incomingNftIds.length; i++){
- const nft: any = await this.getReceivedNFT({
- tokenId: this.incomingNftIds[i]
+ const incomingNft: transferedNft = await t... | frontend/src/views/Bridge.vue | 26 | Vue | 0.071 | suggestion | 35 | 51 | 51 | false | issue-1080-additional-changes | 1,121 | CryptoBlades/cryptoblades | 321 | Vue | Chriserus | kevinunger |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.