@visualizevalue/mint-app-base 0.1.119 → 0.1.121
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/.env.example +0 -1
- package/components/MintTokenBar.vue +1 -2
- package/components/Token/Detail.client.vue +1 -2
- package/components/Token/OverviewCard.vue +2 -1
- package/composables/mintConfig.ts +1 -2
- package/composables/mintDefault.ts +8 -8
- package/nuxt.config.ts +0 -1
- package/package.json +1 -1
package/.env.example
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
type="number"
|
|
6
6
|
v-model="mintCount"
|
|
7
7
|
min="1"
|
|
8
|
-
|
|
8
|
+
step="1"
|
|
9
9
|
required
|
|
10
10
|
class="amount"
|
|
11
11
|
/>
|
|
@@ -41,7 +41,6 @@ const props = defineProps({
|
|
|
41
41
|
mintRequest: Function,
|
|
42
42
|
transactionFlowConfig: Object,
|
|
43
43
|
minted: Function,
|
|
44
|
-
step: { type: Number, default: 1 },
|
|
45
44
|
defaultAmount: { type: Number, default: 1 },
|
|
46
45
|
})
|
|
47
46
|
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
mintRequest,
|
|
42
42
|
transactionFlowConfig,
|
|
43
43
|
minted,
|
|
44
|
-
step,
|
|
45
44
|
defaultAmount,
|
|
46
45
|
}"
|
|
47
46
|
/>
|
|
@@ -74,7 +73,7 @@ const { token } = defineProps<{
|
|
|
74
73
|
const store = useOnchainStore()
|
|
75
74
|
const collection = computed(() => store.collection(token.collection))
|
|
76
75
|
|
|
77
|
-
const { defaultAmount, mintCount
|
|
76
|
+
const { defaultAmount, mintCount } = useMintDefault()
|
|
78
77
|
const ownedBalance = computed(
|
|
79
78
|
() => collection.value && store.tokenBalance(collection.value.address, token.tokenId),
|
|
80
79
|
)
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
mintRequest,
|
|
55
55
|
transactionFlowConfig,
|
|
56
56
|
minted,
|
|
57
|
+
defaultAmount,
|
|
57
58
|
}"
|
|
58
59
|
/>
|
|
59
60
|
<p class="muted" v-if="ownedBalance">
|
|
@@ -73,7 +74,7 @@ const { token } = defineProps<{
|
|
|
73
74
|
const store = useOnchainStore()
|
|
74
75
|
const collection = computed(() => store.collection(token.collection)) as ComputedRef<Collection>
|
|
75
76
|
|
|
76
|
-
const mintCount =
|
|
77
|
+
const { defaultAmount, mintCount } = useMintDefault()
|
|
77
78
|
const ownedBalance = computed(() => store.tokenBalance(collection.value.address, token.tokenId))
|
|
78
79
|
</script>
|
|
79
80
|
|
|
@@ -4,8 +4,7 @@ export const useMintConfig = () => {
|
|
|
4
4
|
|
|
5
5
|
// Query param > ENV > default
|
|
6
6
|
const amount = computed(() => Number(route.query.amount) || Number(config.public.mintAmount) || 1)
|
|
7
|
-
const step = computed(() => Number(route.query.step) || Number(config.public.mintStep) || 1)
|
|
8
7
|
const value = computed(() => Number(route.query.value) || Number(config.public.mintValue) || 0)
|
|
9
8
|
|
|
10
|
-
return { amount,
|
|
9
|
+
return { amount, value }
|
|
11
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const useMintDefault = () => {
|
|
2
|
-
const { amount,
|
|
2
|
+
const { amount, value } = useMintConfig()
|
|
3
3
|
const gasPrice = useGasPrice()
|
|
4
4
|
const priceFeed = usePriceFeedStore()
|
|
5
5
|
|
|
@@ -14,15 +14,15 @@ export const useMintDefault = () => {
|
|
|
14
14
|
// Unit price in wei: basefee * 60_000
|
|
15
15
|
const unitPriceWei = gasPriceWei * 60_000n
|
|
16
16
|
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
17
|
+
// targetCents / unitPriceCents, but computed as a single division
|
|
18
|
+
// to avoid BigInt truncation on the intermediate unitPriceCents:
|
|
19
|
+
// (targetCents * 1e24) / (unitPriceWei * ethUSDRaw)
|
|
20
20
|
const targetCents = BigInt(Math.round(value.value * 100))
|
|
21
|
-
const
|
|
21
|
+
const denominator = unitPriceWei * ethUSDRaw
|
|
22
22
|
|
|
23
|
-
if (!
|
|
23
|
+
if (! denominator) return amount.value
|
|
24
24
|
|
|
25
|
-
return Math.max(1, Number(targetCents /
|
|
25
|
+
return Math.max(1, Number(targetCents * (10n ** 24n) / denominator))
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
// Persist across navigations so the value survives remounts
|
|
@@ -30,5 +30,5 @@ export const useMintDefault = () => {
|
|
|
30
30
|
|
|
31
31
|
watch(defaultAmount, (v) => { mintCount.value = String(v) })
|
|
32
32
|
|
|
33
|
-
return { defaultAmount, mintCount
|
|
33
|
+
return { defaultAmount, mintCount }
|
|
34
34
|
}
|
package/nuxt.config.ts
CHANGED