-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
feat: Auto teleport V1 #7711
Merged
Merged
feat: Auto teleport V1 #7711
Changes from 7 commits
Commits
Show all changes
130 commits
Select commit
Hold shift + click to select a range
c55e671
add: basic hasEnough and hasEnoughInOtherChains
hassnian 62fbc85
Merge branch 'main' into issue-7643
hassnian 68cd4d9
add: basic auto teleport modal
hassnian 5cd3054
ref: teleport to composables
hassnian 74e389f
add: transaction steps
hassnian 34786b8
add: action transaction
hassnian e0251d3
add: checking funds step
hassnian 4f67599
fix: tootltip text alignment
hassnian 429fa59
add: teleport transaction fee
hassnian b8b8e80
fix: teleport fee
hassnian a95e170
add: show modal action button
hassnian 0059a72
add: check if add teleport fee
hassnian 9566d14
add: welcome to auto teleport modal
hassnian f7d8a6b
ref: modal width
hassnian e60382f
ref: clean up
hassnian 3912f3b
add: auto teleport not available state
hassnian 33122bf
add: auto telport icon
hassnian 0e6ad73
fix typo
hassnian c3290d8
fix: teleport switch states
hassnian b25b5d5
add: retry transactino and added spinner animation
hassnian 1141333
styles: spinner animation
hassnian 2dc0ab8
fix: retry state step item styles
hassnian f1dcc57
ref: added useAutoTeleportTransitionSource
hassnian 9408254
ref: move composables to folder
hassnian bc4c442
add: rmrk2 to kusama
hassnian 0f868b4
fix: bugs and cleanup
hassnian 3f7acaa
ref: rename status to transactions
hassnian 2176c79
fix: deepscan issue
hassnian 5f85a0b
fix: sync amount to teleport while needed
hassnian fb49e38
add: action fee
hassnian f1f3ef6
fix: teleport button states
hassnian 6940c61
fix: missing return
hassnian f83adc0
ref: rename
hassnian f9fa422
add: local amount and action
hassnian 09c1b75
fix: auto teleport can do action
hassnian 58ca5a8
add: transalations
hassnian f8e71f4
ref: rename isError
hassnian bc32e82
ref: move max to utils
hassnian d044811
add: action cancelled state
hassnian 26f096e
add: action retry
hassnian 53df283
ref: auto teleport watch
hassnian 50ac6ad
add: has balance state
hassnian 66cb44a
ref: rename useAutoTeleportTransitionDetails
hassnian 9416a41
ref: added getNativeBalance
hassnian cee92cd
fix: fetch chains balances
hassnian 679fe75
fix: auto teleport icon not reactive sometimes
hassnian c666d36
Merge branch 'main' into issue-7643
hassnian ee18f12
ref: move usemultibalance to useMiltipleBalance
hassnian 52e41c0
ref: unify muliple balance
hassnian 04e67a3
ref: move TransactionStepStatus to utils
hassnian 8f3dcfc
Merge branch 'main' into issue-7643
hassnian 8456f96
Merge branch 'issue-7643' of https://github.com/hassnian/nft-gallery …
hassnian 3a57961
add: action details
hassnian 0bab064
add: utils transaltion
hassnian c79c459
Merge branch 'main' into issue-7643
hassnian e813ee4
add: modal fix paddings and added missing text
hassnian b59a655
fix: lint fiat store
hassnian 6ef4faa
add: real action tx fee
hassnian 1e1b0d5
ref: getActionTransactionFee and fix fee
hassnian 3173dd8
fix: fee buffer
hassnian de908a0
add: action details
hassnian b3940b1
fix: added existential deposit
hassnian f4f901c
fix: no async promise
hassnian 68ab430
fix: current chain trasnferable balance
hassnian 079e5c9
remove: loader
hassnian 3077ddc
add: auto teleport turned on by default
hassnian 0321752
fix: blur effect not centered
hassnian 850f087
fix: auto teleport blur
hassnian 45ca8f6
fix: welcome modal blur
hassnian 18d85f1
fix: tooltip color
hassnian 0942b23
fix: welcome title is size 25px
hassnian afba844
fix: remove placeholder quotes
hassnian fabc269
fix: helper text align
hassnian 09fc705
fix: spinner grey and loading on signed with autoteleport
hassnian e17aa61
fix: auto telport modal scroll
hassnian 9422265
fix: is active state for steps
hassnian 6e088d1
fix: clear modal on close
hassnian f432f09
styles: subheading font size change
hassnian f99457c
fix: add back notEnoughFuns
hassnian 798f39c
fix: dont refetch balances if present
hassnian bd027f2
Merge branch 'main' into issue-7643
hassnian 8877ba0
ref: multiple actions buy
hassnian 166835f
ref: use new autoteleport actions listing
hassnian 208e30c
Merge branch 'main' into issue-7643
hassnian ff82c7f
Merge branch 'main' into issue-7643
hassnian 0669c5d
add: create nft autoteleport
hassnian 79fa379
add: create collection
hassnian f0fd2df
ref: types fixes
hassnian f3c724f
ref: move types to file
hassnian 5aedd0b
fix: step item active
hassnian df9aa47
fix: added back cancelled transactions
hassnian 93214ba
add: header based on actions
hassnian 3496a05
fix: fees and transition change
hassnian 0243991
fix: types
hassnian 54f2711
fix: proxy error
hassnian 3c10dce
fix: auto teleport mint
hassnian 6f6183f
ref: is cancelled
hassnian 3e3aea9
add: map ref types
hassnian fa314c2
add: loading and state update collection mint
hassnian 8c0f458
fix: utils types fix
hassnian b58376f
fix: mint collection loader
hassnian 4583e45
ref: similar types
hassnian 45c1786
Merge branch 'main' into issue-7643
hassnian d95bc75
ref: use optional chain
hassnian 8bc724e
fix: mint less fees issue
hassnian 81dae8f
ref: buy actions
hassnian fc4817c
fix: actions completed
hassnian 0c5353a
remove: hasTransitionBalances
hassnian 21d4a6d
fix: max by value
hassnian f7c6d4b
fix: fetch balance taking too long
hassnian 8667611
ref: use button text addFundsViaOnramp
hassnian 69064a0
add: teleport fetch balances
hassnian 39039f1
styles: mobile responsive modals
hassnian 8130638
fix: teleport loading not ending
hassnian 82cc510
add: block number link
hassnian fedb630
fix: balance fetch interval
hassnian 5771492
fix: autoTeleportStarted state
hassnian bc2ec4e
fix: deepscan issue
hassnian 5e33efe
Merge branch 'main' into issue-7643
hassnian 35491e1
fix: pr review changes
hassnian d3ac178
fix: listing issue
hassnian 4c2f249
ref: pr review handle close
hassnian 7043eb9
fix: unnecessary await
hassnian a1cd273
ref: added ActionsInteractions
hassnian 2e34ac9
ref: auto close delay as prop
hassnian 7ffa2e1
fix: use real mint fees
hassnian 9fe6d3f
Merge branch 'main' into issue-7643
hassnian a401d58
fix: add status
hassnian e36c479
Revert "fix: use real mint fees"
hassnian bf629cf
Merge branch 'main' into issue-7643
hassnian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
components/common/autoTeleport/AutoTeleportActionButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<template> | ||
<div class="is-flex is-flex-direction-column w-full"> | ||
<div | ||
v-if="allowAutoTeleport" | ||
class="is-flex is-justify-content-space-between w-full mb-4"> | ||
<div class="is-flex"> | ||
<p class="has-text-weight-bold"> | ||
{{ $t('autoTeleport.autoTeleport') }} | ||
|
||
<AutoTeleportTooltip :transition="optimalTransition" /> | ||
</p> | ||
</div> | ||
|
||
<NeoSwitch v-model="autoTeleport" data-testid="auto-teleport-switch" /> | ||
</div> | ||
|
||
<NeoButton | ||
:label="autoTeleportLabel" | ||
variant="k-accent" | ||
no-shadow | ||
:disabled="localDisabled" | ||
class="is-flex is-flex-grow-1 btn-height" | ||
@click="submit" /> | ||
|
||
<div | ||
v-if="allowAutoTeleport" | ||
class="is-flex is-justify-content-center mt-4"> | ||
<span class="has-text-grey">Or</span> | ||
|
||
<a class="ml-2" @click="onRampActive = true" | ||
roiLeo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
>+ {{ $t('autoTeleport.addFundsViaOnramp') }}</a | ||
> | ||
</div> | ||
</div> | ||
|
||
<AutoTeleportModal | ||
v-model="isModalOpen" | ||
:transition="optimalTransition" | ||
:can-do-action="hasEnoughInCurrentChain" | ||
:status="status" | ||
@close="isModalOpen = false" | ||
@confirm="transaction" /> | ||
|
||
<OnRampModal v-model="onRampActive" @close="onRampActive = false" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { NeoButton, NeoSwitch } from '@kodadot1/brick' | ||
import { Actions } from '@/composables/transaction/types' | ||
import OnRampModal from '@/components/shared/OnRampModal.vue' | ||
|
||
const props = defineProps<{ | ||
amount: number | ||
label: string | ||
action: Actions | ||
}>() | ||
|
||
const { $i18n } = useNuxtApp() | ||
const { chainSymbol, name } = useChain() | ||
const { | ||
canTeleport, | ||
hasEnoughInCurrentChain, | ||
hasEnoughInRichestChain, | ||
optimalTransition, | ||
teleport, | ||
status, | ||
transaction, | ||
} = useAutoTeleport( | ||
props.action, | ||
computed(() => props.amount), | ||
) | ||
|
||
const isModalOpen = ref(false) | ||
const onRampActive = ref(false) | ||
const autoTeleport = ref(false) | ||
|
||
const allowAutoTeleport = computed( | ||
() => | ||
!hasEnoughInCurrentChain.value && | ||
hasEnoughInRichestChain.value && | ||
optimalTransition.value.source && | ||
canTeleport.value, | ||
) | ||
|
||
const autoTeleportLabel = computed(() => { | ||
if (!canTeleport.value || hasEnoughInCurrentChain.value) { | ||
return props.label | ||
} | ||
|
||
if (hasEnoughInRichestChain.value && autoTeleport.value) { | ||
return $i18n.t('autoTeleport.teleportAndConfirm') | ||
} | ||
|
||
return $i18n.t('autoTeleport.notEnoughTokenInChain', [ | ||
chainSymbol.value, | ||
name.value, | ||
]) | ||
}) | ||
|
||
const localDisabled = computed(() => { | ||
if ( | ||
hasEnoughInRichestChain.value && | ||
canTeleport.value && | ||
autoTeleport.value | ||
) { | ||
return false | ||
} | ||
|
||
if (hasEnoughInCurrentChain.value) { | ||
return false | ||
} | ||
|
||
return true | ||
}) | ||
|
||
const openAutoTeleportModal = () => { | ||
isModalOpen.value = true | ||
|
||
teleport({ | ||
onError: () => { | ||
isModalOpen.value = false | ||
}, | ||
}) | ||
} | ||
|
||
const submit = () => { | ||
if (allowAutoTeleport.value) { | ||
openAutoTeleportModal() | ||
} else { | ||
transaction() | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.btn-height { | ||
roiLeo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
height: 3.5rem; | ||
} | ||
</style> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Is it possible that the item is equal to
null
orundefined
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here again.
do not close conversations on behalf of the reviewer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duly noted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is there any clarification here? 👀