Skip to content

Commit

Permalink
feat: bump valibot version
Browse files Browse the repository at this point in the history
Check https://valibot.dev/guides/migrate-to-v0.31.0/ if you were using valibot for types creation
  • Loading branch information
dawidsowardx committed Sep 23, 2024
1 parent ab6e22a commit 6d3ef6c
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 132 deletions.
18 changes: 13 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/dapp-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"rxjs": "^7.8.1",
"tslog": ">=4.8.0",
"uuid": "^10.0.0",
"valibot": "0.30.0"
"valibot": "0.42.1"
},
"devDependencies": {
"@radixdlt/connect-button": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const validateWalletResponse = (
): ResultAsync<WalletInteractionSuccessResponse, SdkError> => {
const fn = Result.fromThrowable(
(_) => parse(WalletInteractionResponse, _),
(error) => error as ValiError,
(error) => error as ValiError<any>,
)

const result = fn(walletResponse)
Expand Down
16 changes: 8 additions & 8 deletions packages/dapp-toolkit/src/modules/state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ import {
object,
variant,
string,
Output,
InferOutput,
} from 'valibot'

export const proofType = {
persona: 'persona',
account: 'account',
} as const

export type SignedChallengePersona = Output<typeof SignedChallengePersona>
export type SignedChallengePersona = InferOutput<typeof SignedChallengePersona>
export const SignedChallengePersona = object({
challenge: string(),
proof: Proof,
address: string(),
type: literal(proofType.persona),
})

export type SignedChallengeAccount = Output<typeof SignedChallengeAccount>
export type SignedChallengeAccount = InferOutput<typeof SignedChallengeAccount>
export const SignedChallengeAccount = object({
challenge: string(),
proof: Proof,
address: string(),
type: literal(proofType.account),
})

export type SignedChallenge = Output<typeof SignedChallenge>
export type SignedChallenge = InferOutput<typeof SignedChallenge>
export const SignedChallenge = variant('type', [
SignedChallengePersona,
SignedChallengeAccount,
Expand All @@ -59,22 +59,22 @@ export const WalletDataPersonaDataPhoneNumbersAddresses = object({
fields: array(string()),
})

export type WalletDataPersonaData = Output<typeof WalletDataPersonaData>
export type WalletDataPersonaData = InferOutput<typeof WalletDataPersonaData>
export const WalletDataPersonaData = variant('entry', [
WalletDataPersonaDataFullName,
WalletDataPersonaDataEmailAddresses,
WalletDataPersonaDataPhoneNumbersAddresses,
])

export type WalletData = Output<typeof WalletData>
export type WalletData = InferOutput<typeof WalletData>
export const WalletData = object({
accounts: array(Account),
personaData: array(WalletDataPersonaData),
persona: optional(Persona),
proofs: array(SignedChallenge),
})

export type SharedData = Output<typeof SharedData>
export type SharedData = InferOutput<typeof SharedData>
export const SharedData = object({
persona: optional(object({ proof: boolean() })),
ongoingAccounts: optional(
Expand All @@ -86,7 +86,7 @@ export const SharedData = object({
ongoingPersonaData: optional(PersonaDataRequestItem),
})

export type RdtState = Output<typeof RdtState>
export type RdtState = InferOutput<typeof RdtState>
export const RdtState = object({
loggedInTimestamp: string(),
walletData: WalletData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { produce } from 'immer'
import { boolean, object, Output, optional } from 'valibot'
import { boolean, object, InferOutput, optional } from 'valibot'
import { NumberOfValues } from '../../../../schemas'

export type AccountsRequestBuilder = {
Expand All @@ -13,7 +13,7 @@ export type OneTimeAccountsRequestBuilder = {
exactly: (n: number) => OneTimeAccountsRequestBuilder
withProof: (value?: boolean) => OneTimeAccountsRequestBuilder
}
export type AccountsDataRequest = Output<typeof AccountsDataRequestSchema>
export type AccountsDataRequest = InferOutput<typeof AccountsDataRequestSchema>

export const AccountsDataRequestSchema = object({
numberOfAccounts: NumberOfValues,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { produce } from 'immer'
import { boolean, object, Output, partial } from 'valibot'
import { boolean, object, InferOutput, partial } from 'valibot'
import { NumberOfValues } from '../../../../schemas'

export type PersonaDataRequestBuilder = {
Expand All @@ -13,7 +13,7 @@ export type OneTimePersonaDataRequestBuilder = {
emailAddresses: (value?: boolean) => PersonaDataRequestBuilder
phoneNumbers: (value?: boolean) => PersonaDataRequestBuilder
}
export type PersonaDataRequest = Output<typeof PersonaDataRequestSchema>
export type PersonaDataRequest = InferOutput<typeof PersonaDataRequestSchema>

export const PersonaDataRequestSchema = partial(
object({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { produce } from 'immer'
import { boolean, object, Output, optional } from 'valibot'
import { boolean, object, InferOutput, optional } from 'valibot'

export type PersonaRequestBuilder = {
withProof: (value?: boolean) => PersonaRequestBuilder
}
export type PersonaRequest = Output<typeof schema>
export type PersonaRequest = InferOutput<typeof schema>

const schema = object({
withProof: optional(boolean()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { NumberOfValues } from '../../../../schemas'
import { produce } from 'immer'
import type { Result } from 'neverthrow'
import { ok } from 'neverthrow'
import { boolean, object, string, Output, optional } from 'valibot'
import { boolean, object, string, InferOutput, optional } from 'valibot'

export type TransformRdtDataRequestToWalletRequestInput = Output<
export type TransformRdtDataRequestToWalletRequestInput = InferOutput<
typeof TransformRdtDataRequestToWalletRequestInput
>
export const TransformRdtDataRequestToWalletRequestInput = object({
Expand Down
Loading

0 comments on commit 6d3ef6c

Please sign in to comment.