Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
6354b5db
Commit
6354b5db
authored
Apr 24, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass custom app url to iframe
parent
c75cac05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
8 deletions
+32
-8
MarketplaceApp.tsx
ui/pages/MarketplaceApp.tsx
+27
-5
ActionButton.tsx
ui/shared/ActionButton.tsx
+5
-3
No files found.
ui/pages/MarketplaceApp.tsx
View file @
6354b5db
...
...
@@ -2,7 +2,7 @@ import { Box, Center, useColorMode, Flex } from '@chakra-ui/react';
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
{
DappscoutIframeProvider
,
useDappscoutIframe
}
from
'
dappscout-iframe
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
,
{
useCallback
,
useEffect
,
useState
}
from
'
react
'
;
import
React
,
{
useCallback
,
useEffect
,
useState
,
useMemo
}
from
'
react
'
;
import
type
{
MarketplaceAppOverview
}
from
'
types/client/marketplace
'
;
...
...
@@ -16,6 +16,7 @@ import throwOnResourceLoadError from 'lib/errors/throwOnResourceLoadError';
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
*
as
metadata
from
'
lib/metadata
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
removeQueryParam
from
'
lib/router/removeQueryParam
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
MarketplaceAppTopBar
from
'
../marketplace/MarketplaceAppTopBar
'
;
...
...
@@ -36,9 +37,10 @@ type Props = {
address
:
string
|
undefined
;
data
:
MarketplaceAppOverview
|
undefined
;
isPending
:
boolean
;
appUrl
?:
string
;
};
const
MarketplaceAppContent
=
({
address
,
data
,
isPending
}:
Props
)
=>
{
const
MarketplaceAppContent
=
({
address
,
data
,
isPending
,
appUrl
}:
Props
)
=>
{
const
{
iframeRef
,
isReady
}
=
useDappscoutIframe
();
const
[
iframeKey
,
setIframeKey
]
=
useState
(
0
);
...
...
@@ -89,7 +91,7 @@ const MarketplaceAppContent = ({ address, data, isPending }: Props) => {
h=
"100%"
w=
"100%"
display=
{
isFrameLoading
?
'
none
'
:
'
block
'
}
src=
{
data
.
u
rl
}
src=
{
appU
rl
}
title=
{
data
.
title
}
onLoad=
{
handleIframeLoad
}
/>
...
...
@@ -132,6 +134,26 @@ const MarketplaceApp = () => {
const
{
data
,
isPending
}
=
query
;
const
{
setIsAutoConnectDisabled
}
=
useMarketplaceContext
();
const
appUrl
=
useMemo
(()
=>
{
if
(
!
data
?.
url
)
{
return
;
}
try
{
const
customUrl
=
getQueryParamString
(
router
.
query
.
url
);
const
customOrigin
=
new
URL
(
customUrl
).
origin
;
const
appOrigin
=
new
URL
(
data
.
url
).
origin
;
if
(
customOrigin
===
appOrigin
)
{
return
customUrl
;
}
else
{
removeQueryParam
(
router
,
'
url
'
);
}
}
catch
(
err
)
{}
return
data
.
url
;
},
[
data
?.
url
,
router
]);
useEffect
(()
=>
{
if
(
data
)
{
metadata
.
update
(
...
...
@@ -153,13 +175,13 @@ const MarketplaceApp = () => {
/>
<
DappscoutIframeProvider
address=
{
address
}
appUrl=
{
data
?.
u
rl
}
appUrl=
{
appU
rl
}
rpcUrl=
{
config
.
chain
.
rpcUrl
}
sendTransaction=
{
sendTransaction
}
signMessage=
{
signMessage
}
signTypedData=
{
signTypedData
}
>
<
MarketplaceAppContent
address=
{
address
}
data=
{
data
}
isPending=
{
isPending
}
/>
<
MarketplaceAppContent
address=
{
address
}
data=
{
data
}
isPending=
{
isPending
}
appUrl=
{
appUrl
}
/>
</
DappscoutIframeProvider
>
</
Flex
>
);
...
...
ui/shared/ActionButton.tsx
View file @
6354b5db
import
{
Button
,
Image
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
LinkExternal
from
'
./LinkExternal
'
;
type
Props
=
{
...
...
@@ -15,8 +17,8 @@ type Props = {
}
const
mockData
=
{
appId
:
'
1
'
,
actionUrl
:
'
https://
github.com/
'
,
appId
:
'
uniswap
'
,
actionUrl
:
'
https://
app.uniswap.org/swap?inputCurrency=ETH&outputCurrency=0x6B175474E89094C44Da98b954EedeAC495271d0F
'
,
textColor
:
'
#E2E8F0
'
,
bgColor
:
'
#9747FF
'
,
text
:
'
Mint NFT
'
,
...
...
@@ -47,7 +49,7 @@ const ActionButton = ({ data = mockData }: Props) => {
return
appId
?
(
<
Button
as=
"a"
href=
{
actionUrl
}
href=
{
route
({
pathname
:
'
/apps/[id]
'
,
query
:
{
id
:
appId
,
action
:
'
connect
'
,
url
:
actionUrl
}
})
}
display=
"flex"
size=
"sm"
px=
{
2
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment