Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 40 additions & 21 deletions packages/wallet/frontend/src/pages/grant-interactions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const GrantInteractionPage = ({
grant,
interactionId,
nonce,
clientName
clientName,
grantWalletAddress
}: GrantInteractionPageProps) => {
const [openDialog, closeDialog] = useDialog()
const router = useRouter()
Expand Down Expand Up @@ -66,30 +67,41 @@ const GrantInteractionPage = ({
width={500}
height={150}
/>
<div className="mt-20 text-base">
{grant.access.length === 1 ? (
{grantWalletAddress.length > 0 ? (
<div className="mt-20 text-base">
<div>
{client} is requesting access to make payments to an amount of{' '}
{grant.access[0]?.limits?.debitAmount?.formattedAmount}.
<span className="font-semibold">{grant.client}</span> is
requesting you to confirm ownership of the following wallet
address(es):&nbsp;
{grantWalletAddress.join(', ')}
</div>
) : (
</div>
) : (
<div className="mt-20 text-base">
{grant.access.length === 1 ? (
<div>
{client} is requesting access to make payments to an amount of{' '}
{grant.access[0]?.limits?.debitAmount?.formattedAmount}.
</div>
) : (
<div>
{client} is requesting access to make payments on the following
amounts:{' '}
{grant.access
.map(
(accessItem) =>
accessItem.limits?.debitAmount?.formattedAmount
)
.join(', ')}
.
</div>
)}
<div>
{client} is requesting access to make payments on the following
amounts:{' '}
{grant.access
.map(
(accessItem) =>
accessItem.limits?.debitAmount?.formattedAmount
)
.join(', ')}
.
Wallet Address client:{' '}
<span className="font-semibold">{grant.client}</span>
</div>
)}
<div>
Wallet Address client:{' '}
<span className="font-semibold">{grant.client}</span>
</div>
</div>
)}
<div className="mx-auto mt-10 flex w-full max-w-xl justify-evenly">
<Button
aria-label="accept"
Expand Down Expand Up @@ -168,6 +180,7 @@ export const getServerSideProps: GetServerSideProps<{
interactionId: string
nonce: string
clientName: string
grantWalletAddress: string[]
}> = async (ctx) => {
const result = querySchema.safeParse(ctx.query)
if (!result.success) {
Expand Down Expand Up @@ -217,12 +230,18 @@ export const getServerSideProps: GetServerSideProps<{
})
grantInteractionResponse.result.client = result.data.clientUri

const walletAddressList: string[] = []
grantInteractionResponse.result.subject?.sub_ids.map((subID) =>
walletAddressList.push(subID.id)
)

return {
props: {
grant: grantInteractionResponse.result,
interactionId: result.data.interactId,
nonce: result.data.nonce,
clientName: result.data.clientName
clientName: result.data.clientName,
grantWalletAddress: walletAddressList
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/wallet/shared/src/types/grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,23 @@ type Access = {
} | null
}

type Subject = {
sub_ids: [
{
id: string
format: string
}
]
}

export interface GrantResponse {
id: string
client: string
state: GrantState
createdAt: string
access: Access[]
finalizationReason?: GrantFinalization
subject?: Subject
}

type GrantNode = {
Expand Down