-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add experimental/smart-session (#2875)
Co-authored-by: tomiir <rocchitomas@gmail.com>
- Loading branch information
1 parent
c5a2107
commit d0f4d54
Showing
54 changed files
with
2,562 additions
and
1,175 deletions.
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
47 changes: 47 additions & 0 deletions
47
apps/laboratory/src/components/SmartSessionGrantedPermissionsInfo.tsx
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,47 @@ | ||
import * as React from 'react' | ||
import { StackDivider, Heading, Box, Stack, Text } from '@chakra-ui/react' | ||
import { getChain } from '../utils/NetworksUtil' | ||
import { formatDistanceToNow } from 'date-fns' | ||
import type { SmartSessionGrantPermissionsResponse } from '@reown/appkit-experimental/smart-session' | ||
|
||
export function SmartSessionGrantedPermissionsInfo({ | ||
grantedPermissions | ||
}: { | ||
grantedPermissions: SmartSessionGrantPermissionsResponse | undefined | ||
}) { | ||
if (!grantedPermissions?.context) { | ||
return ( | ||
<Text fontSize="md" color="yellow"> | ||
Dapp does not have any stored permissions | ||
</Text> | ||
) | ||
} | ||
|
||
const { address, chainId, expiry } = grantedPermissions | ||
const parsedExpiry = formatDistanceToNow(new Date(expiry * 1000), { addSuffix: true }) | ||
const parsedChainId = parseInt(chainId, 16) | ||
const chain = getChain(parsedChainId) | ||
|
||
return ( | ||
<Stack direction={['column', 'column', 'row']} divider={<StackDivider />} spacing="4"> | ||
<Box> | ||
<Heading size="xs" textTransform="uppercase" pb="2"> | ||
Account Address | ||
</Heading> | ||
<Text>{address}</Text> | ||
</Box> | ||
<Box> | ||
<Heading size="xs" textTransform="uppercase" pb="2"> | ||
Chain Id | ||
</Heading> | ||
<Text>{chain?.name || chainId}</Text> | ||
</Box> | ||
<Box> | ||
<Heading size="xs" textTransform="uppercase" pb="2"> | ||
Expiry | ||
</Heading> | ||
<Text>{parsedExpiry}</Text> | ||
</Box> | ||
</Stack> | ||
) | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/laboratory/src/components/Wagmi/WagmiPermissionsAsyncTest.tsx
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
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
Oops, something went wrong.