Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Campaign logic #1016

Merged
merged 8 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/images/dapp_promotions/algem.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions src/components/assets/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
<div class="container">
<div class="row--details">
<div class="column-account-name">
<au-icon
<!-- <au-icon
v-if="isAccountUnified"
:native-address="unifiedAccount?.nativeAddress"
:icon-url="unifiedAccount?.avatarUrl"
/>
/> -->
<img
v-else-if="iconWallet"
width="24"
:src="iconWallet"
alt="wallet-icon"
Expand Down Expand Up @@ -94,7 +93,7 @@ import { $api } from 'src/boot/api';
import EvmNativeToken from 'src/components/assets/EvmNativeToken.vue';
import NativeAssetList from 'src/components/assets/NativeAssetList.vue';
import ZkAstr from 'src/components/assets/ZkAstr.vue';
import AuIcon from 'src/components/header/modals/account-unification/AuIcon.vue';
// import AuIcon from 'src/components/header/modals/account-unification/AuIcon.vue';
import { endpointKey, providerEndpoints } from 'src/config/chainEndpoints';
import { supportWalletObj } from 'src/config/wallets';
import {
Expand All @@ -117,7 +116,6 @@ export default defineComponent({
NativeAssetList,
EvmNativeToken,
ZkAstr,
AuIcon,
},
props: {
ttlErc20Amount: {
Expand Down
48 changes: 6 additions & 42 deletions src/components/dapp-staking/my-staking/DynamicAdsArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
}"
>
<swiper-slide v-for="(item, index) in items" :key="index">
<swiper-slide v-for="(item, index) in combinedCampaigns" :key="index">
<div
class="card--swiper"
@click="item.link !== undefined ? goToLink(item.link) : goDappPageLink(item.address)"
Expand All @@ -35,41 +35,33 @@
</div>
<div class="text--name">{{ item.name }}</div>
</div>
<div class="text--description">{{ item.description }}</div>
<div class="text--description">{{ item.shortDescription }}</div>
</div>
</div>
</swiper-slide>
</swiper>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, watchEffect, computed } from 'vue';
import dappPromotions from 'src/data/dapp_promotions.json';
import { defineComponent } from 'vue';
import { networkParam, Path } from 'src/router/routes';
import { useRouter } from 'vue-router';
import { useCampaign } from 'src/hooks';

// Import Swiper
import { Swiper, SwiperSlide } from 'swiper/vue';
import 'swiper/css';
import 'swiper/css/navigation';
import { Navigation } from 'swiper/modules';

interface Data {
name: string;
description: string;
img: string;
link?: string;
address?: string;
}

export default defineComponent({
components: {
Swiper,
SwiperSlide,
},
setup() {
const items = ref<Data[]>([]);
const router = useRouter();
const { combinedCampaigns } = useCampaign();

const goToLink = (link: string): void => {
window.open(link, '_blank');
Expand All @@ -81,37 +73,9 @@ export default defineComponent({
router.push(url);
};

// dummy data
const newListing = [
{
address: '0x95f506e72777efcb3c54878bb4160b00cd11cd84',
name: 'Lucky',
description:
'New listing1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris rutrum.',
img: '/images/dapp_promotions/new.webp',
},
{
address: '0x95f506e72777efcb3c54878bb4160b00cd11cd84',
name: 'Lucky',
description:
'New listing2 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris rutrum.',
img: '/images/dapp_promotions/new.webp',
},
];

const maxLength = Math.max(newListing.length, dappPromotions.length);
for (let i = 0; i < maxLength; i++) {
if (i < newListing.length) {
items.value.push(newListing[i]);
}
if (i < dappPromotions.length) {
items.value.push(dappPromotions[i]);
}
}

return {
modules: [Navigation],
items,
combinedCampaigns,
goToLink,
goDappPageLink,
};
Expand Down
64 changes: 8 additions & 56 deletions src/data/dapp_promotions.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,14 @@
[
{
"name":"Beyond Club",
"description": "Campaign1",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign1.webp"
"name": "Algem - Liquid Staking",
"shortDescription": "Receive one liquid nASTR token for every ASTR token you stake. Then use nASTR to yield farm on the ecosystem to maximize your earnings.",
"link": "https://www.algem.io/",
"img": "images/dapp_promotions/algem.jpg"
},
{
"name":"Beyond Club",
"description": "Campaign2 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign2.webp"
},
{
"name":"Beyond Club",
"description": "Campaign3",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign3.webp"
},
{
"name":"Beyond Club",
"description": "Campaign4",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign4.webp"
},
{
"name":"Beyond Club",
"description": "Campaign5",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign5.webp"
},
{
"name":"Beyond Club",
"description": "Campaign6",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign6.webp"
},
{
"name":"Beyond Club",
"description": "Campaign7",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign7.webp"
},
{
"name":"Beyond Club",
"description": "Campaign8",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign8.webp"
},
{
"name":"Beyond Club",
"description": "Campaign9",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign9.webp"
},
{
"name":"Beyond Club",
"description": "Campaign10",
"link": "https://astar.network/",
"img": "/images/dapp_promotions/campaign10.webp"
"name": "ASTR token, value and utility",
"shortDescription": "How the ASTR Token Brings Utility and Value to the Astar Ecosystem",
"link": "https://astar.network/blog/how-the-astr-token-brings-utility-and-value-to-the-astar-39387",
"img": "https://ipfs.subsocial.network/ipfs/bafybeig2o6zjlnxnwgdv6xkcgu4w5tn7wdre26kimpc2w2ldrum66cotw4"
}
]
45 changes: 45 additions & 0 deletions src/hooks/dapps-staking/useCampaign.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { computed } from 'vue';
import { useStore } from 'src/store';
import { Campaign, DappCombinedInfo } from 'src/v2/models';
import dappPromotions from 'src/data/dapp_promotions.json';

export function useCampaign() {
const dappsInCampaign = 5;
const store = useStore();

// Latest registered dApps.
const newListings = computed<Campaign[]>(() =>
(<DappCombinedInfo[]>store.getters['dapps/getAllDapps'])
.filter((x) => !!x.dapp)
.sort((x, y) => Number(y.dapp?.creationTime ?? 0) - Number(x.dapp?.creationTime ?? 0))
.splice(0, dappsInCampaign)
.map(
(x) =>
<Campaign>{
name: x.dapp?.name,
shortDescription: x.dapp?.shortDescription,
link: x.dapp?.url,
img: x.dapp?.imagesUrl ? x.dapp.imagesUrl[0] : 'images/noimage.png',
address: x.contract.address,
}
)
);

// Combine latest dApps with dApp promotions.
const combinedCampaigns = computed<Campaign[]>(() => {
const result: Campaign[] = [];
const minLen = Math.min(newListings.value.length, dappPromotions.length);

for (let i = 0; i < minLen; i++) {
result.push(newListings.value[i], dappPromotions[i]);
}
result.push(...newListings.value.slice(minLen), ...dappPromotions.slice(minLen));

return result;
});

return {
newListings,
combinedCampaigns,
};
}
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export * from './dapps-staking/useStakingList';
export * from './dapps-staking/useSignPayload';
export * from './dapps-staking/useDappRedirect';
export * from './dapps-staking/useDispatchGetDapps';
export * from './dapps-staking/useCampaign';
export * from './wallet/useWalletIcon';
export * from './wallet/useEvmWallet';
export * from './wallet/useLedger';
Expand Down
8 changes: 8 additions & 0 deletions src/v2/models/DappsStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ export interface AccountLedger {
export interface DappStakingConstants {
maxEraStakeValues: number;
}

export interface Campaign {
name: string;
shortDescription: string;
link?: string;
img: string;
address?: string;
}
Loading