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

fix: Not possible to play with generative art drop page when not connected #7895

Merged
merged 1 commit into from
Nov 1, 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
3 changes: 2 additions & 1 deletion components/collection/drop/Generative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ const mintButtonDisabled = computed(() =>
Boolean(
currentMintedLoading.value ||
!mintCountAvailable.value ||
!selectedImage.value,
!selectedImage.value ||
!accountId.value,
),
)

Expand Down
16 changes: 9 additions & 7 deletions components/collection/drop/GenerativePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
:loading="isLoading"
no-shadow
loading-with-label
:disabled="!accountId"
@click="generateNft">
@click="generateNft()">
{{
$t(
isLoading
Expand Down Expand Up @@ -64,7 +63,10 @@ const getHash = (isDefault?: boolean) => {
? chainProperties.value?.ss58Format
: getRandomInt(15000)
// https://github.com/paritytech/ss58-registry/blob/30889d6c9d332953a6e3333b30513eef89003f64/ss58-registry.json#L1292C17-L1292C22
return stringToHex(encodeAddress(accountId.value, ss58Format))
return accountId.value
? stringToHex(encodeAddress(accountId.value, ss58Format))
: // random value
ss58Format
}

const generativeImageUrl = ref(
Expand All @@ -73,15 +75,15 @@ const generativeImageUrl = ref(

const isLoading = ref(false)

onMounted(() => {
generativeImageUrl.value && emit('select', generativeImageUrl.value)
watch([accountId], () => {
generateNft(true)
})
const displayUrl = computed(() => {
return generativeImageUrl.value || props.image
})
const generateNft = async () => {
const generateNft = (isDefault: boolean = false) => {
isLoading.value = true
const metadata = `${props.content}/?hash=${getHash()}`
const metadata = `${props.content}/?hash=${getHash(isDefault)}`
generativeImageUrl.value = metadata
emit('select', generativeImageUrl.value)

Expand Down