Skip to content

Commit df332b0

Browse files
committed
Simplet POAP fixes
1 parent a133a0e commit df332b0

8 files changed

Lines changed: 36 additions & 8 deletions

File tree

frontend/components/parts/airdrop/AirdropModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const methods = [
4848
},
4949
];
5050
51-
const availableNFTs = computed(() => maxSupply - userStore.users.length - items.value.length - 1000);
51+
const availableNFTs = computed(() => maxSupply - userStore.users.length - items.value.length);
5252
5353
const isButtonDisabled = computed(() => {
5454
switch (uploadStep.value) {
@@ -150,7 +150,7 @@ async function deploy() {
150150
}
151151
userStore.balance = 0;
152152
153-
uploadStep.value = res ? Step.DEPLOYED : Step.REVIEW;
153+
uploadStep.value = res ? Step.DEPLOYED : Step.DATA;
154154
}
155155
</script>
156156

frontend/components/parts/form/Share.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ onMounted(async () => {
3535
<p class="mb-4">{{ metadata.description }}</p>
3636

3737
<!-- Transaction -->
38-
<a v-if="txHash" :href="transactionLink(txHash)" class="hover:underline" target="_blank">
38+
<a
39+
v-if="txHash"
40+
:href="transactionLink(txHash, config.public.CHAIN_ID)"
41+
class="hover:underline"
42+
target="_blank"
43+
>
3944
Transaction: {{ shortHash(txHash) }}
4045
</a>
4146
</div>

frontend/components/parts/poap/PoapInfo.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
size="sm"
88
/>
99
</div>
10-
<n-checkbox v-model:checked="immediatelyShowQr" class="mt-2 mb-1"> Immediately show QR code </n-checkbox>
10+
<n-checkbox v-if="Number(config.public.CLAIM_START) > 0" v-model:checked="immediatelyShowQr" class="mt-2 mb-1">
11+
Immediately show QR code (for testing purposes)
12+
</n-checkbox>
1113
<BtnLink
1214
:link="`${domain}/poap/scan-qr?immediatelyShowQr=${immediatelyShowQr}${stringifyQuery(currentRoute.query, '&')}`"
1315
/>
@@ -24,9 +26,11 @@
2426
</template>
2527

2628
<script lang="ts" setup>
29+
const config = useRuntimeConfig();
30+
const { currentRoute } = useRouter();
31+
2732
const domain = window.location.origin;
2833
const immediatelyShowQr = ref(false);
29-
const { currentRoute } = useRouter();
3034
3135
async function navigateToReserveDrop() {
3236
try {

frontend/composables/useClaim.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ export default function useClaim() {
7272
const uri = await contract.value.read.tokenURI([id]);
7373
return await parseLink(uri);
7474
}
75+
async function getTotalSupply(): Promise<number> {
76+
if (!contractStore.totalSupply) {
77+
await initContract();
78+
const max = await contract.value.read.totalSupply([]);
79+
contractStore.totalSupply = max >= maxUint32 ? Number.MAX_SAFE_INTEGER : Number(max);
80+
}
81+
return contractStore.totalSupply;
82+
}
7583

7684
async function isAutoIncrement(): Promise<boolean> {
7785
if (contractStore.autoIncrement === null) {
@@ -87,7 +95,11 @@ export default function useClaim() {
8795
if (!nftId) {
8896
const balance = await getBalance();
8997
if (Number(balance) === 0) return null;
98+
} else {
99+
const totalSupply = await getTotalSupply();
100+
if (Number(nftId) > totalSupply) return null;
90101
}
102+
91103
const id = nftId || (await getTokenOfOwner(0));
92104
const url = await getTokenUri(Number(id));
93105
const parsedUrl = await parseLink(url);
@@ -106,6 +118,7 @@ export default function useClaim() {
106118
await ensureCorrectNetwork();
107119
let success: any = false;
108120
const image = await parseLink(metadata?.image || '');
121+
contractStore.totalSupply += 1;
109122

110123
try {
111124
if (wallet.value && info.activeWallet?.address) {
@@ -193,6 +206,7 @@ export default function useClaim() {
193206
addNftId,
194207
contractError,
195208
getMaxSupply,
209+
getTotalSupply,
196210
getName,
197211
isAutoIncrement,
198212
loadNft,

frontend/composables/useWalletConnect.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default function useWalletConnect() {
4545
}
4646

4747
async function login(admin = false) {
48+
if (authStore.loggedIn && !admin) modalWalletVisible.value = false;
4849
if (loading.value || authStore.loggedIn || !admin) return;
4950

5051
loading.value = true;

frontend/lib/misc/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const ErrorCodes = {
8383
422006: 'Captcha verification is required. Please solve the captcha.',
8484
422007: 'Captcha error. Please solve the captcha again.',
8585
422008: 'User has already minted. Duplicate minting is not allowed.',
86-
422009: 'Wallet belongs to another user. Please log in with a different wallet.',
86+
422009: 'User with this wallet address already exists. Please use a different wallet.',
8787
422013: 'Wallet address is not valid.',
8888
422014: 'Email or wallet address is required. Please provide one of them.',
8989

frontend/pages/poap/reserve-nft.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const router = useRouter();
7979
const message = useMessage();
8080
8181
const { query } = useRoute();
82-
const { loadNft } = useClaim();
82+
const { getTotalSupply, loadNft } = useClaim();
8383
const { parseLink } = useIpns();
8484
const { handleError } = useErrors();
8585
const { connected } = useWalletConnect();
@@ -90,6 +90,7 @@ const tokenValidityInPercent = ref(100);
9090
const dropReserved = ref(false);
9191
const nfts = ref<Array<string>>([]);
9292
const token = query.nftToken?.toString();
93+
const totalSupply = await getTotalSupply();
9394
9495
let calcRemainingTimeInterval: any = null as any;
9596
@@ -132,7 +133,7 @@ onMounted(() => {
132133
}
133134
134135
const tokenIssueDate = Number(dayjs(decoded.iat * 1000));
135-
isTokenValid.value = Number(dayjs()) - tokenIssueDate < 7000;
136+
isTokenValid.value = Number(dayjs()) - tokenIssueDate < 12000;
136137
137138
calcRemainingTimeInterval = setInterval(() => {
138139
const currDate = dayjs();
@@ -173,6 +174,8 @@ function loadImages() {
173174
[1, 2, 3, 4, 5].forEach(i => loadImage(i));
174175
}
175176
async function loadImage(i: number) {
177+
if (i > totalSupply) return;
178+
176179
const metadata = await loadNft(i);
177180
178181
const image = await parseLink(metadata?.image || '');

frontend/stores/contract.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const useContractStore = defineStore('contract', {
77
balance: 0n,
88
name: '',
99
maxSupply: 0,
10+
totalSupply: 0,
1011
}),
1112

1213
getters: {},

0 commit comments

Comments
 (0)