Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing response types & rename discriminator #266

Merged
merged 1 commit into from
Oct 15, 2024
Merged
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
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
Loading