15
15
  ; (<router-link :to =" `/address/${hash}/${tokenId}`" >#{{ tokenId }}</router-link >)
16
16
</span >
17
17
<span v-if =" hash && !copied && !notCopiable" >
18
-   ; <v-icon class =" text-medium-emphasis" @click =" copyHash()" size =" x-small" >mdi-content-copy</v-icon ><input type =" hidden" :id =" `copyElement-${hash}`" :value =" hash" >
18
+   ; <v-icon class =" text-medium-emphasis" @click =" copyHash()" size =" x-small" >mdi-content-copy</v-icon ><input type =" hidden" :id =" `copyElement-${hash}`" :value =" alternateLink && showAlternateLink ? alternateLink : hash" >
19
19
</span >
20
20
<span v-if =" copied" >
21
21
  ; <v-icon class =" text-medium-emphasis" size =" x-small" >mdi-check</v-icon >
22
22
</span >
23
+ <span v-if =" alternateLink" >
24
+   ; <v-icon class =" text-medium-emphasis" size =" x-small" @click =" showAlternateLink = !showAlternateLink" >mdi-swap-horizontal</v-icon >
25
+ </span >
23
26
</span >
24
27
</template >
25
28
<script >
26
29
import { inject } from ' vue' ;
27
30
import { mapStores } from ' pinia' ;
28
31
import { useExplorerStore } from ' ../stores/explorer' ;
32
+ import { useCustomisationStore } from ' ../stores/customisation' ;
29
33
import { sanitize } from ' ../lib/utils' ;
30
34
31
35
export default {
@@ -36,11 +40,17 @@ export default {
36
40
token: null ,
37
41
contractName: null ,
38
42
verified: false ,
43
+ alternateLink: null ,
44
+ showAlternateLink: false
39
45
}),
40
46
setup () {
41
47
const isEmbedded = inject (' isEmbedded' , false );
42
48
return { embedded: !! isEmbedded };
43
49
},
50
+ mounted () {
51
+ if (this .type == ' address' )
52
+ this .setupAlternateLink ();
53
+ },
44
54
watch: {
45
55
hash: {
46
56
immediate: true ,
@@ -82,21 +92,17 @@ export default {
82
92
}
83
93
},
84
94
computed: {
85
- ... mapStores (useExplorerStore),
95
+ ... mapStores (useExplorerStore, useCustomisationStore ),
86
96
formattedHash () {
87
- if (! this .hash ) return ;
88
- if (this .fullHash ) {
89
- return this .hash ;
90
- }
91
- else if (this .xsHash ) {
92
- return ` ${ this .hash .slice (0 , 5 )} ...${ this .hash .slice (- 4 )} ` ;
93
- }
94
- else {
95
- return ` ${ this .hash .slice (0 , 8 )} ...${ this .hash .slice (- 4 )} ` ;
96
- }
97
+ if (this .alternateLink && this .showAlternateLink )
98
+ return this .formatHash (this .alternateLink );
99
+ else
100
+ return this .formatHash (this .hash );
97
101
},
98
102
name () {
99
- if (this .customLabel )
103
+ if (this .alternateLink && this .showAlternateLink )
104
+ return this .formatHash (this .alternateLink );
105
+ else if (this .customLabel )
100
106
return this .customLabel ;
101
107
if (this .withName != false && this .explorerStore .faucet && this .hash == this .explorerStore .faucet .address )
102
108
return ` ${ this .explorerStore .token || ' ETH' } faucet` ;
@@ -111,6 +117,26 @@ export default {
111
117
externalLink () { return ` //${ this .explorerStore .domain } /${ [this .type , this .hash ].join (' /' )} ` ; }
112
118
},
113
119
methods: {
120
+ setupAlternateLink () {
121
+ this .customisationStore .alternateLink (this .hash )
122
+ .then (result => {
123
+ this .alternateLink = result;
124
+ if (! result) {
125
+ let unsubscribe = this .customisationStore .$subscribe ((mutation , state ) => {
126
+ if (state .worker ) {
127
+ unsubscribe ();
128
+ this .setupAlternateLink ();
129
+ }
130
+ });
131
+ }
132
+ });
133
+ },
134
+ formatHash (hash ) {
135
+ if (! hash) return ;
136
+ if (this .fullHash ) return hash;
137
+ else if (this .xsHash ) return ` ${ hash .slice (0 , 5 )} ...${ hash .slice (- 4 )} ` ;
138
+ else return ` ${ hash .slice (0 , 8 )} ...${ hash .slice (- 4 )} ` ;
139
+ },
114
140
copyHash () {
115
141
const webhookField = document .querySelector (` #copyElement-${ this .hash } ` );
116
142
webhookField .setAttribute (' type' , ' text' );
0 commit comments