@visualizevalue/mint-app-base 0.1.126 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/components/Collection/Withdraw.client.vue +1 -1
- package/components/MintTokenBar.vue +1 -0
- package/components/Token/MintTimeline.client.vue +1 -43
- package/components/TransactionFlow.vue +29 -9
- package/components/TransactionToasts.vue +43 -0
- package/composables/collections.ts +57 -266
- package/composables/transactions.ts +51 -0
- package/nuxt.config.ts +1 -0
- package/package.json +29 -1
- package/plugins/2.5.dapp-query.client.ts +40 -0
- package/plugins/transaction-toasts.client.ts +13 -0
- package/queries/index.ts +144 -0
- package/queries/sources.ts +417 -0
- package/.env.example +0 -50
- package/.nuxtrc +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Visualize Value
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
error: 'Retry',
|
|
18
18
|
complete: 'OK',
|
|
19
19
|
},
|
|
20
|
-
}" skip-confirmation auto-close-success @complete="onComplete">
|
|
20
|
+
}" skip-confirmation auto-close-success toast @complete="onComplete">
|
|
21
21
|
<template #start="{ start }">
|
|
22
22
|
<Button @click="start">
|
|
23
23
|
<Icon type="withdraw" />
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
:block="currentBlock"
|
|
17
17
|
>
|
|
18
18
|
<template #after>
|
|
19
|
-
<TokenMintTimelineItem
|
|
19
|
+
<TokenMintTimelineItem>
|
|
20
20
|
<Account :address="collection.owner" class="account" />
|
|
21
21
|
|
|
22
22
|
<span class="amount">1<span>×</span></span>
|
|
@@ -34,17 +34,12 @@
|
|
|
34
34
|
</TokenMintTimelineVirtualScroller>
|
|
35
35
|
</template>
|
|
36
36
|
|
|
37
|
-
<div v-if="! backfillComplete" v-show="! loading" ref="loadMore" class="load-more">
|
|
38
|
-
<Button @click="backfill">{{ $t('token.load_more')}}</Button>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
37
|
<Loading v-if="loading || ! currentBlock" :txt="$t('token.loading_mint_history')" />
|
|
42
38
|
</slot>
|
|
43
39
|
</section>
|
|
44
40
|
</template>
|
|
45
41
|
|
|
46
42
|
<script setup>
|
|
47
|
-
import { useElementVisibility } from '@vueuse/core'
|
|
48
43
|
import { useBlockNumber } from '@wagmi/vue'
|
|
49
44
|
|
|
50
45
|
const config = useRuntimeConfig()
|
|
@@ -58,7 +53,6 @@ const { token, collection } = defineProps({
|
|
|
58
53
|
const state = useOnchainStore()
|
|
59
54
|
|
|
60
55
|
const mints = computed(() => state.tokenMints(token.collection, token.tokenId))
|
|
61
|
-
const backfillComplete = computed(() => token.mintsBackfilledUntilBlock <= token.mintedBlock)
|
|
62
56
|
|
|
63
57
|
const sortBy = ref('recent')
|
|
64
58
|
const sortedMints = computed(() => {
|
|
@@ -72,46 +66,17 @@ const sortedMints = computed(() => {
|
|
|
72
66
|
})
|
|
73
67
|
|
|
74
68
|
const loading = ref(true)
|
|
75
|
-
const loadMore = ref()
|
|
76
|
-
const loadMoreVisible = useElementVisibility(loadMore)
|
|
77
|
-
const backfill = async () => {
|
|
78
|
-
loading.value = true
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
await state.backfillTokenMints(token)
|
|
82
|
-
|
|
83
|
-
// If we're not fully backfilled and we have less than 20 mints loaded,
|
|
84
|
-
// continue backfilling events.
|
|
85
|
-
while (! backfillComplete.value && mints.value?.length < 20) {
|
|
86
|
-
await delay(250)
|
|
87
|
-
await state.backfillTokenMints(token)
|
|
88
|
-
}
|
|
89
|
-
} catch (e) {
|
|
90
|
-
console.error(`Issue during backfill`, e)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
loading.value = false
|
|
94
|
-
}
|
|
95
69
|
|
|
96
70
|
onMounted(async () => {
|
|
97
71
|
loading.value = true
|
|
98
72
|
try {
|
|
99
|
-
console.info(`Attempting to load + backfill token mints for #${token.tokenId}`)
|
|
100
73
|
await state.fetchTokenMints(token)
|
|
101
|
-
await backfill()
|
|
102
74
|
} catch (e) {
|
|
103
75
|
console.error(e)
|
|
104
76
|
}
|
|
105
77
|
loading.value = false
|
|
106
78
|
})
|
|
107
79
|
|
|
108
|
-
watch(loadMoreVisible, () => {
|
|
109
|
-
// Skip if we have enough mints for the viewport or we're already loading
|
|
110
|
-
if (! loadMoreVisible.value || loading.value) return
|
|
111
|
-
|
|
112
|
-
backfill()
|
|
113
|
-
})
|
|
114
|
-
|
|
115
80
|
watch(currentBlock, () => {
|
|
116
81
|
if (loading.value) return
|
|
117
82
|
|
|
@@ -171,11 +136,4 @@ watch(currentBlock, () => {
|
|
|
171
136
|
}
|
|
172
137
|
}
|
|
173
138
|
|
|
174
|
-
|
|
175
|
-
.load-more {
|
|
176
|
-
.button {
|
|
177
|
-
display: block;
|
|
178
|
-
width: 100%;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
139
|
</style>
|
|
@@ -35,10 +35,12 @@
|
|
|
35
35
|
|
|
36
36
|
<script setup>
|
|
37
37
|
import { waitForTransactionReceipt, watchChainId } from '@wagmi/core'
|
|
38
|
+
|
|
38
39
|
const checkChain = useEnsureChainIdCheck()
|
|
39
40
|
|
|
40
41
|
const { $wagmi } = useNuxtApp()
|
|
41
42
|
const config = useRuntimeConfig()
|
|
43
|
+
const txStore = useTransactionStore()
|
|
42
44
|
const props = defineProps({
|
|
43
45
|
text: {
|
|
44
46
|
type: Object,
|
|
@@ -65,10 +67,12 @@ const props = defineProps({
|
|
|
65
67
|
},
|
|
66
68
|
skipConfirmation: Boolean,
|
|
67
69
|
autoCloseSuccess: Boolean,
|
|
70
|
+
toast: Boolean,
|
|
68
71
|
})
|
|
69
72
|
|
|
70
73
|
const emit = defineEmits(['complete', 'cancel'])
|
|
71
74
|
|
|
75
|
+
|
|
72
76
|
const open = ref(false)
|
|
73
77
|
|
|
74
78
|
const switchChain = ref(false)
|
|
@@ -147,14 +151,30 @@ const initializeRequest = async (request = cachedRequest.value) => {
|
|
|
147
151
|
requesting.value = true
|
|
148
152
|
tx.value = await request()
|
|
149
153
|
requesting.value = false
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
|
|
155
|
+
if (!props.toast) {
|
|
156
|
+
// Blocking mode: wait for receipt in the modal (used for multi-step flows)
|
|
157
|
+
waiting.value = true
|
|
158
|
+
const [receiptObject] = await Promise.all([
|
|
159
|
+
waitForTransactionReceipt($wagmi, { hash: tx.value }),
|
|
160
|
+
])
|
|
161
|
+
await delay(props.delayAfter)
|
|
162
|
+
receipt.value = receiptObject
|
|
163
|
+
emit('complete', receiptObject)
|
|
164
|
+
complete.value = true
|
|
165
|
+
} else {
|
|
166
|
+
// Toast mode: close modal and track in background
|
|
167
|
+
open.value = false
|
|
168
|
+
txStore.track(
|
|
169
|
+
tx.value,
|
|
170
|
+
props.text.lead?.waiting || 'Transaction submitted...',
|
|
171
|
+
props.text.lead?.complete || 'Transaction confirmed.',
|
|
172
|
+
(receiptObject) => {
|
|
173
|
+
receipt.value = receiptObject
|
|
174
|
+
emit('complete', receiptObject)
|
|
175
|
+
},
|
|
176
|
+
)
|
|
177
|
+
}
|
|
158
178
|
} catch (e) {
|
|
159
179
|
if (e?.cause?.code === 4001) {
|
|
160
180
|
open.value = false
|
|
@@ -167,7 +187,7 @@ const initializeRequest = async (request = cachedRequest.value) => {
|
|
|
167
187
|
requesting.value = false
|
|
168
188
|
waiting.value = false
|
|
169
189
|
|
|
170
|
-
if (props.autoCloseSuccess && step.value === 'complete') {
|
|
190
|
+
if (!props.toast && props.autoCloseSuccess && step.value === 'complete') {
|
|
171
191
|
await delay(props.delayAutoclose)
|
|
172
192
|
open.value = false
|
|
173
193
|
await delay(300) // Animations...
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<TransitionGroup name="fade" tag="div" class="transaction-toasts">
|
|
3
|
+
<a
|
|
4
|
+
v-for="tx in txStore.pending"
|
|
5
|
+
:key="tx.hash"
|
|
6
|
+
:href="tx.txLink"
|
|
7
|
+
target="_blank"
|
|
8
|
+
class="transaction-toast"
|
|
9
|
+
>
|
|
10
|
+
<Icon
|
|
11
|
+
:type="tx.status === 'waiting' ? 'loader' : 'check'"
|
|
12
|
+
:class="{ spin: tx.status === 'waiting' }"
|
|
13
|
+
/>
|
|
14
|
+
<span>{{ tx.status === 'complete' ? tx.completeText : tx.waitingText }}</span>
|
|
15
|
+
</a>
|
|
16
|
+
</TransitionGroup>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
const txStore = useTransactionStore()
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
.transaction-toasts {
|
|
25
|
+
position: fixed;
|
|
26
|
+
top: var(--navbar-height);
|
|
27
|
+
right: var(--size-6);
|
|
28
|
+
z-index: 100;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
gap: var(--spacer-sm);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.transaction-toast {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
gap: var(--spacer-sm);
|
|
38
|
+
padding: var(--ui-padding-y) var(--ui-padding-x);
|
|
39
|
+
background: var(--background);
|
|
40
|
+
border: var(--border);
|
|
41
|
+
font-size: var(--font-sm);
|
|
42
|
+
}
|
|
43
|
+
</style>
|