Skip to content

Commit

Permalink
fix: add missing response types & rename discriminator
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidsowardx committed Oct 15, 2024
1 parent 94e543a commit 4ccd67c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/simple-dapp/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ subintentButton.onclick = async () => {
childSubintentHashes: [],
expiration: {
discriminator: 'expireAfterSignature',
value: '3600',
value: 3600,
},
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { validateRolaChallenge, type Logger } from '../../helpers'
import { TransactionStatus } from '../gateway'
import { ResultAsync, err, ok, okAsync } from 'neverthrow'
import type {
ExpireAfterSignature,
ExpireAtTime,
MessageLifeCycleEvent,
WalletInteraction,
} from '../../schemas'
Expand Down Expand Up @@ -311,7 +309,7 @@ export const WalletRequestModule = (input: {
SdkError
> => {
const walletInteraction = walletRequestSdk.createWalletInteraction({
discriminator: 'preAuthorizedRequest',
discriminator: 'preAuthorizationRequest',
subintent: {
discriminator: 'subintent',
blobs: value.blobs,
Expand Down
15 changes: 12 additions & 3 deletions packages/dapp-toolkit/src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ export const CancelRequest = object({
export type ExpireAtTime = InferOutput<typeof ExpireAtTime>
export const ExpireAtTime = object({
discriminator: literal('expireAtTime'),
value: string(),
value: number(),
})

export type ExpireAfterSignature = InferOutput<typeof ExpireAfterSignature>
export const ExpireAfterSignature = object({
discriminator: literal('expireAfterSignature'),
value: string(),
value: number(),
})

export type SubintentRequestItem = InferOutput<typeof SubintentRequestItem>
Expand All @@ -277,7 +277,7 @@ export type WalletPreAuthorizationItems = InferOutput<
typeof WalletPreAuthorizationItems
>
export const WalletPreAuthorizationItems = object({
discriminator: literal('preAuthorizedRequest'),
discriminator: literal('preAuthorizationRequest'),
subintent: optional(SubintentRequestItem),
})

Expand Down Expand Up @@ -332,6 +332,14 @@ export const AuthLoginWithChallengeRequestResponseItem = object({
proof: Proof,
})

export type WalletPreAuthorizationResponseItems = InferOutput<
typeof WalletPreAuthorizationResponseItems
>
export const WalletPreAuthorizationResponseItems = object({
discriminator: literal('preAuthorizationRequest'),
subintent: optional(SubintentResponseItem),
})

export const AuthLoginRequestResponseItem = union([
AuthLoginWithoutChallengeRequestResponseItem,
AuthLoginWithChallengeRequestResponseItem,
Expand Down Expand Up @@ -380,6 +388,7 @@ export type WalletInteractionResponseItems = InferOutput<
const WalletInteractionResponseItems = union([
WalletRequestResponseItems,
WalletTransactionResponseItems,
WalletPreAuthorizationResponseItems,
])

export type WalletInteractionSuccessResponse = InferOutput<
Expand Down

0 comments on commit 4ccd67c

Please sign in to comment.