-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tangle-dapp): Get Permitted Caller for Tangle Dapp (#2303)
- Loading branch information
1 parent
c60ff46
commit 66f18a5
Showing
14 changed files
with
254 additions
and
295 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
112 changes: 112 additions & 0 deletions
112
apps/tangle-dapp/app/services/[serviceId]/PermittedCaller.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,112 @@ | ||
'use client'; | ||
|
||
import { getExplorerURI } from '@webb-tools/api-provider-environment/transaction/utils'; | ||
import { | ||
CodeFile, | ||
CopyWithTooltip, | ||
ExternalLinkIcon, | ||
shortenHex, | ||
Typography, | ||
} from '@webb-tools/webb-ui-components'; | ||
import { FC } from 'react'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
import SkeletonRow from '../../../components/skeleton/SkeletonRow'; | ||
import useNetworkStore from '../../../context/useNetworkStore'; | ||
import { usePermittedCaller } from '../../../data/serviceDetails'; | ||
|
||
interface PermittedCallerProps { | ||
className?: string; | ||
} | ||
|
||
const PermittedCaller: FC<PermittedCallerProps> = ({ className }) => { | ||
const { network } = useNetworkStore(); | ||
const { permittedCaller, codeData, isLoading, error } = usePermittedCaller(); | ||
|
||
return ( | ||
<div className={twMerge('space-y-5', className)}> | ||
<div className="flex items-center justify-between"> | ||
<Typography variant="h4" fw="bold"> | ||
Permitted Caller | ||
</Typography> | ||
{permittedCaller && ( | ||
<div className="flex items-center gap-1.5"> | ||
<Typography variant="body1"> | ||
{shortenHex(permittedCaller)} | ||
</Typography> | ||
<CopyWithTooltip | ||
textToCopy={permittedCaller} | ||
isButton={false} | ||
iconClassName="!fill-mono-160 dark:!fill-mono-80" | ||
/> | ||
{network.evmExplorerUrl && ( | ||
<ExternalLinkIcon | ||
href={getExplorerURI( | ||
network.evmExplorerUrl, | ||
permittedCaller, | ||
'address', | ||
'web3' | ||
).toString()} | ||
className="!fill-mono-160 dark:!fill-mono-80" | ||
/> | ||
)} | ||
</div> | ||
)} | ||
</div> | ||
<div | ||
className={twMerge( | ||
'bg-glass dark:bg-glass_dark', | ||
'h-full p-6 rounded-2xl flex flex-col', | ||
'border border-mono-0 dark:border-mono-160', | ||
className | ||
)} | ||
> | ||
{/* Loading */} | ||
{isLoading && <SkeletonRow />} | ||
|
||
{/* Error */} | ||
{!isLoading && error !== null && ( | ||
<Typography variant="body1" color="error"> | ||
Error | ||
</Typography> | ||
)} | ||
|
||
{/* No Permitted Caller */} | ||
{!isLoading && | ||
error === null && | ||
permittedCaller === null && | ||
codeData === null && ( | ||
<Typography variant="body1"> | ||
No Permitted Caller was provided | ||
</Typography> | ||
)} | ||
|
||
{/* Permitted Caller available but not a contract */} | ||
{!isLoading && | ||
error === null && | ||
permittedCaller !== null && | ||
codeData === null && ( | ||
<Typography variant="body1"> | ||
The code for Permitted Caller is not available since it is not a | ||
smart contract. | ||
</Typography> | ||
)} | ||
|
||
{/* Permitted Caller is a contract */} | ||
{!isLoading && | ||
error === null && | ||
permittedCaller !== null && | ||
codeData !== null && ( | ||
<CodeFile | ||
code={codeData.sourceCode} | ||
isInNextProject | ||
className="bg-mono-20 dark:bg-mono-200 overflow-auto max-h-[740px]" | ||
language={codeData.language} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PermittedCaller; |
69 changes: 0 additions & 69 deletions
69
apps/tangle-dapp/app/services/[serviceId]/SigningRules.tsx
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { default as getSigningRules } from './getSigningRules'; | ||
export { default as usePermittedCaller } from './usePermittedCaller'; | ||
export { default as useServiceInfoCard } from './useServiceInfoCard'; | ||
export { default as useServiceJobs } from './useServiceJobs'; | ||
export { default as useServiceParticipants } from './useServiceParticipants'; |
Oops, something went wrong.