Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xstelea committed Jul 14, 2023
1 parent 22b196e commit 3b9ac33
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
56 changes: 30 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ yarn add @radixdlt/wallet-sdk
import { WalletSdk } from '@radixdlt/wallet-sdk'

const walletSdk = WalletSdk({
version: 1,
networkId: 12,
dAppDefinitionAddress:
'account_tdx_c_1p8j5r3umpgdwpedqssn0mwnwj9tv7ae7wfzjd9srwh5q9stufq',
Expand All @@ -57,7 +56,6 @@ const walletSdk = WalletSdk({

```typescript
type Metadata = {
version: number
networkId: number
dAppDefinitionAddress: string
}
Expand All @@ -68,7 +66,6 @@ type Metadata = {
| Mainnet | 1 |
| RCNet-V1 | 12 |
- **requires** version - API version of the wallet communication protocol.
- **requires** networkId - Specifies which network to use
- **requires** dAppDefinitionAddress - Specifies the dApp that is interacting with the wallet. Used in dApp verification process on the wallet side.
Expand Down Expand Up @@ -113,7 +110,7 @@ This request type is for getting one or more Radix accounts managed by the user'
### Request
```typescript
type NumberOfAccounts = {
type NumberOfValues = {
quantifier: 'exactly' | 'atLeast'
quantity: number
}
Expand All @@ -122,7 +119,7 @@ type NumberOfAccounts = {
```typescript
type AccountsRequestItem = {
challenge?: Challenge
numberOfAccounts: NumberOfAccounts
numberOfAccounts: NumberOfValues
}
```
Expand Down Expand Up @@ -271,32 +268,25 @@ This request type is for a list of personal data fields associated with the user

### Request

```typescript
type PersonaDataField =
| 'givenName'
| 'familyName'
| 'emailAddress'
| 'phoneNumber'
```
```typescript
type PersonaDataRequestItem = {
fields: PersonaDataField[]
isRequestingName?: boolean()
numberOfRequestedEmailAddresses?: NumberOfValues
numberOfRequestedPhoneNumbers?: NumberOfValues
}
```
### Response
```typescript
type PersonaData = {
field: PersonaDataField
value: string
}
```
```typescript
type PersonaDataRequestResponseItem = {
fields: PersonaData[]
name?: {
variant: 'eastern' | 'western'
family: string
given: string
}
emailAddresses?: NumberOfValues
phoneNumbers?: NumberOfValues
}
```
Expand All @@ -309,7 +299,9 @@ const result = await sdk.request({
discriminator: 'authorizedRequest',
auth: { discriminator: 'loginWithoutChallenge' },
ongoingPersonaData: {
fields: ['givenName'],
isRequestingName: true,
numberOfRequestedEmailAddresses: { quantifier: 'atLeast', quantity: 1 },
numberOfRequestedPhoneNumbers: { quantifier: 'exactly', quantity: 1 },
},
})

Expand All @@ -324,9 +316,16 @@ if (result.isErr()) {
// persona: Persona
// },
// ongoingPersonaData: {
// fields: PersonaData[]
// name: {
// variant: 'western',
// given: 'John',
// family: 'Conner'
// },
// emailAddresses: ['jc@resistance.ai'],
// phoneNumbers: ['123123123']
// }
// }

const value = result.value
```

Expand All @@ -340,7 +339,7 @@ const value = result.value
const result = await sdk.request({
discriminator: 'unauthorizedRequest',
oneTimePersonaData: {
fields: ['givenName'],
isRequestingName: true,
},
})

Expand All @@ -351,9 +350,14 @@ if (result.isErr()) {
// {
// discriminator: "unauthorizedRequest",
// oneTimePersonaData: {
// fields: PersonaData[]
// name: {
// variant: 'eastern',
// given: 'Jet',
// family: 'Li'
// }
// }
// }

const value = result.value
```

Expand Down
2 changes: 1 addition & 1 deletion examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ document.getElementById('login-btn')!.onclick = async () => {
})
if (result.isErr()) return
result.value.discriminator === 'authorizedRequest' &&
result.value.ongoingPersonaData?.fullName!.given!
result.value.ongoingPersonaData?.name!.given!

displayResults(result)
}
Expand Down
6 changes: 3 additions & 3 deletions lib/IO/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export const PersonaDataNameVariant = union([
literal(personaDataFullNameVariant.western),
])

export type PersonaDataFullName = z.infer<typeof PersonaDataFullName>
export const PersonaDataFullName = object({
export type PersonaDataName = z.infer<typeof PersonaDataName>
export const PersonaDataName = object({
variant: PersonaDataNameVariant,
familyName: string(),
nickname: string(),
Expand Down Expand Up @@ -79,7 +79,7 @@ export type PersonaDataRequestResponseItem = z.infer<
typeof PersonaDataRequestResponseItem
>
export const PersonaDataRequestResponseItem = object({
fullName: PersonaDataFullName.optional(),
name: PersonaDataName.optional(),
emailAddresses: array(string()).optional(),
phoneNumbers: array(string()).optional(),
})
Expand Down

0 comments on commit 3b9ac33

Please sign in to comment.