@luxexchange/api 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +22 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +56 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/use-token-list.d.ts +22 -0
- package/dist/hooks/use-token-list.d.ts.map +1 -0
- package/dist/hooks/use-token-list.js +27 -0
- package/dist/hooks/use-token-price.d.ts +15 -0
- package/dist/hooks/use-token-price.d.ts.map +1 -0
- package/dist/hooks/use-token-price.js +63 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/package.json +10 -11
- package/project.json +2 -8
- package/src/clients/base/SharedQueryClient.ts +2 -2
- package/src/clients/base/errors.test.ts +39 -0
- package/src/clients/base/errors.ts +9 -1
- package/src/clients/base/urls.test.ts +7 -7
- package/src/clients/base/urls.ts +5 -5
- package/src/clients/base/utils.test.ts +2 -2
- package/src/clients/blockaid/createBlockaidApiClient.ts +1 -1
- package/src/clients/compliance/createComplianceApiClient.ts +40 -0
- package/src/clients/compliance/types.ts +15 -0
- package/src/clients/data/createDataServiceApiClient.ts +1 -1
- package/src/clients/dataApi/createDataApiServiceClient.ts +4 -4
- package/src/clients/dataApi/getGetPortfolioQueryOptions.test.ts +4 -4
- package/src/clients/dataApi/getGetPortfolioQueryOptions.ts +10 -6
- package/src/clients/embeddedWallet/createEmbeddedWalletApiClient.ts +254 -82
- package/src/clients/for/createForApiClient.ts +4 -4
- package/src/clients/for/utils.ts +1 -1
- package/src/clients/gasService/createGasServiceClient.ts +21 -0
- package/src/clients/graphql/queries.graphql +0 -183
- package/src/clients/graphql/queries.ts +0 -2
- package/src/clients/graphql/schema.graphql +603 -594
- package/src/clients/graphql/web/activity.graphql +0 -6
- package/src/clients/graphql/web/landing.graphql +0 -20
- package/src/clients/graphql/web/token.graphql +21 -3
- package/src/clients/lux/createLuxApiClient.ts +4 -21
- package/src/clients/trading/api.json +1 -1
- package/src/clients/trading/createTradingApiClient.ts +8 -8
- package/src/clients/trading/types.ts +1 -1
- package/src/clients/unitags/createUnitagsApiClient.test.ts +1 -1
- package/src/clients/unitags/createUnitagsApiClient.ts +5 -5
- package/src/clients/x/createXVerificationServiceClient.ts +26 -0
- package/src/components/ApiInit.test.tsx +2 -2
- package/src/components/ApiInit.tsx +5 -5
- package/src/connectRpc/utils.ts +1 -1
- package/src/getEntryGatewayUrl.ts +1 -1
- package/src/getWebSocketUrl.ts +10 -7
- package/src/hooks/shared/useQueryWithImmediateGarbageCollection.ts +1 -1
- package/src/hooks/useIsSessionInitialized.ts +1 -1
- package/src/index.ts +86 -59
- package/src/provideSessionService.native.ts +2 -2
- package/src/provideSessionService.ts +3 -3
- package/src/provideSessionService.web.ts +8 -8
- package/src/session/createSessionTransport.test.ts +1 -1
- package/src/session/createWithSessionRetry.ts +1 -1
- package/src/session/index.ts +1 -1
- package/src/storage/createExtensionStorageDriver.ts +1 -1
- package/src/storage/getStorageDriver.ts +1 -1
- package/src/storage/getStorageDriver.web.ts +1 -1
- package/src/transport.ts +1 -1
- package/stubs/privy-service-pb.d.ts +150 -3
- package/.depcheckrc +0 -17
- package/.eslintrc.js +0 -30
- package/src/clients/graphql/web/nft/CollectionSearch.graphql +0 -34
- package/src/clients/graphql/web/portfolios.graphql +0 -68
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type PartialMessage } from '@bufbuild/protobuf'
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query'
|
|
3
3
|
import type { GetPortfolioRequest, GetPortfolioResponse } from '@uniswap/client-data-api/dist/data/v1/api_pb'
|
|
4
|
-
import { type DataApiServiceClient } from '@
|
|
5
|
-
import { transformInput, type WithoutWalletAccount } from '@
|
|
6
|
-
import { ReactQueryCacheKey } from '
|
|
7
|
-
import { type QueryOptionsResult } from '
|
|
4
|
+
import { type DataApiServiceClient } from '@universe/api/src/clients/dataApi/createDataApiServiceClient'
|
|
5
|
+
import { transformInput, type WithoutWalletAccount } from '@universe/api/src/connectRpc/utils'
|
|
6
|
+
import { ReactQueryCacheKey } from 'utilities/src/reactQuery/cache'
|
|
7
|
+
import { type QueryOptionsResult } from 'utilities/src/reactQuery/queryOptions'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Sorts `chainIds` in a query cache inputs object so that the same logical input
|
|
@@ -51,9 +51,13 @@ export function getGetPortfolioQueryOptions(
|
|
|
51
51
|
): QueryOptionsResult<GetPortfolioResponse | undefined, Error, GetPortfolioResponse | undefined, GetPortfolioQueryKey> {
|
|
52
52
|
const transformedInput = transformInput(input)
|
|
53
53
|
|
|
54
|
-
const { modifier
|
|
54
|
+
const { modifier, walletAccount: _walletAccount, ...queryCacheInputs } = transformedInput ?? {}
|
|
55
55
|
|
|
56
|
-
const queryCacheInputsSorted = sortQueryCacheInputs(
|
|
56
|
+
const queryCacheInputsSorted = sortQueryCacheInputs({
|
|
57
|
+
...queryCacheInputs,
|
|
58
|
+
includeSmallBalances: modifier?.includeSmallBalances,
|
|
59
|
+
includeSpamTokens: modifier?.includeSpamTokens,
|
|
60
|
+
})
|
|
57
61
|
|
|
58
62
|
const addressKey = {
|
|
59
63
|
...(input?.evmAddress && { evmAddress: input.evmAddress }),
|
|
@@ -1,47 +1,68 @@
|
|
|
1
1
|
import { type PromiseClient } from '@connectrpc/connect'
|
|
2
2
|
import { EmbeddedWalletService as OldEmbeddedWalletService } from '@uniswap/client-embeddedwallet/dist/uniswap/embeddedwallet/v1/service_connect'
|
|
3
3
|
import {
|
|
4
|
-
type DeleteAuthenticatorResponse,
|
|
5
4
|
type ExportSeedPhraseResponse,
|
|
6
|
-
type ListAuthenticatorsResponse,
|
|
7
5
|
type Action as OldAction,
|
|
8
6
|
type AuthenticationTypes as OldAuthenticationTypes,
|
|
9
|
-
type RegisterNewAuthenticatorResponse,
|
|
10
7
|
type SecuredChallengeResponse,
|
|
11
8
|
} from '@uniswap/client-embeddedwallet/dist/uniswap/embeddedwallet/v1/service_pb'
|
|
12
9
|
import {
|
|
10
|
+
type AddAuthenticatorResponse,
|
|
13
11
|
type ChallengeResponse,
|
|
14
12
|
type CreateWalletResponse,
|
|
13
|
+
type DeleteAuthenticatorResponse,
|
|
14
|
+
type DeleteRecoveryResponse,
|
|
15
15
|
type DisconnectResponse,
|
|
16
|
+
type ExecuteRecoveryResponse,
|
|
17
|
+
type GetRecoveryConfigResponse,
|
|
18
|
+
type ListAuthenticatorsResponse,
|
|
16
19
|
type Action as NewAction,
|
|
17
20
|
type AuthenticationTypes as NewAuthenticationTypes,
|
|
21
|
+
type OprfEvaluateResponse,
|
|
18
22
|
type RegistrationOptions,
|
|
23
|
+
type ReportDecryptionResultResponse,
|
|
24
|
+
type SetupRecoveryResponse,
|
|
19
25
|
type SignMessageResponse,
|
|
20
26
|
type SignTransactionResponse,
|
|
21
27
|
type SignTypedDataResponse,
|
|
28
|
+
type StartAuthenticatedSessionResponse,
|
|
22
29
|
type WalletSignInResponse,
|
|
23
30
|
} from '@uniswap/client-privy-embedded-wallet/dist/uniswap/privy-embedded-wallet/v1/service_pb'
|
|
24
31
|
|
|
25
32
|
export type {
|
|
26
|
-
DeleteAuthenticatorResponse,
|
|
27
33
|
ExportSeedPhraseResponse,
|
|
28
|
-
ListAuthenticatorsResponse,
|
|
29
|
-
RegisterNewAuthenticatorResponse,
|
|
30
34
|
SecuredChallengeResponse,
|
|
31
35
|
} from '@uniswap/client-embeddedwallet/dist/uniswap/embeddedwallet/v1/service_pb'
|
|
32
36
|
export type {
|
|
33
37
|
Action,
|
|
38
|
+
AddAuthenticatorResponse,
|
|
34
39
|
AuthenticationTypes,
|
|
40
|
+
Authenticator,
|
|
35
41
|
ChallengeResponse,
|
|
36
42
|
CreateWalletResponse,
|
|
43
|
+
DeleteAuthenticatorResponse,
|
|
44
|
+
DeleteRecoveryResponse,
|
|
37
45
|
DisconnectResponse,
|
|
46
|
+
ExecuteRecoveryResponse,
|
|
47
|
+
GetRecoveryConfigResponse,
|
|
48
|
+
ListAuthenticatorsResponse,
|
|
49
|
+
OprfEvaluateResponse,
|
|
50
|
+
RecoveryMethod,
|
|
38
51
|
RegistrationOptions,
|
|
52
|
+
ReportDecryptionResultResponse,
|
|
53
|
+
SetupRecoveryResponse,
|
|
39
54
|
SignMessageResponse,
|
|
40
55
|
SignTransactionResponse,
|
|
41
56
|
SignTypedDataResponse,
|
|
57
|
+
StartAuthenticatedSessionResponse,
|
|
42
58
|
WalletSignInResponse,
|
|
43
59
|
} from '@uniswap/client-privy-embedded-wallet/dist/uniswap/privy-embedded-wallet/v1/service_pb'
|
|
44
60
|
|
|
61
|
+
export type SignAuth =
|
|
62
|
+
| { case: 'credential'; value: string }
|
|
63
|
+
| { case: 'deviceAuth'; value: { deviceSignature: string; walletId: string } }
|
|
64
|
+
| { case: undefined; value?: undefined }
|
|
65
|
+
|
|
45
66
|
export interface EmbeddedWalletClientContext {
|
|
46
67
|
rpcClient: {
|
|
47
68
|
challenge: (req: Record<string, unknown>) => Promise<ChallengeResponse>
|
|
@@ -51,6 +72,16 @@ export interface EmbeddedWalletClientContext {
|
|
|
51
72
|
signTransaction: (req: Record<string, unknown>) => Promise<SignTransactionResponse>
|
|
52
73
|
signTypedData: (req: Record<string, unknown>) => Promise<SignTypedDataResponse>
|
|
53
74
|
disconnect: (req: Record<string, unknown>) => Promise<DisconnectResponse>
|
|
75
|
+
listAuthenticators: (req: Record<string, unknown>) => Promise<ListAuthenticatorsResponse>
|
|
76
|
+
startAuthenticatedSession: (req: Record<string, unknown>) => Promise<StartAuthenticatedSessionResponse>
|
|
77
|
+
addAuthenticator: (req: Record<string, unknown>) => Promise<AddAuthenticatorResponse>
|
|
78
|
+
deleteAuthenticator: (req: Record<string, unknown>) => Promise<DeleteAuthenticatorResponse>
|
|
79
|
+
oprfEvaluate: (req: Record<string, unknown>) => Promise<OprfEvaluateResponse>
|
|
80
|
+
setupRecovery: (req: Record<string, unknown>) => Promise<SetupRecoveryResponse>
|
|
81
|
+
executeRecovery: (req: Record<string, unknown>) => Promise<ExecuteRecoveryResponse>
|
|
82
|
+
reportDecryptionResult: (req: Record<string, unknown>) => Promise<ReportDecryptionResultResponse>
|
|
83
|
+
getRecoveryConfig: (req: Record<string, unknown>) => Promise<GetRecoveryConfigResponse>
|
|
84
|
+
deleteRecovery: (req: Record<string, unknown>) => Promise<DeleteRecoveryResponse>
|
|
54
85
|
}
|
|
55
86
|
legacyRpcClient?: PromiseClient<typeof OldEmbeddedWalletService>
|
|
56
87
|
}
|
|
@@ -64,30 +95,32 @@ export interface EmbeddedWalletApiClient {
|
|
|
64
95
|
message?: string
|
|
65
96
|
transaction?: string
|
|
66
97
|
typedData?: string
|
|
98
|
+
authenticatorId?: string
|
|
99
|
+
devicePublicKey?: string
|
|
100
|
+
authPublicKey?: string
|
|
101
|
+
privyUserId?: string
|
|
67
102
|
}) => Promise<ChallengeResponse>
|
|
68
103
|
|
|
69
|
-
fetchCreateWalletRequest: (params: { credential: string }) => Promise<CreateWalletResponse>
|
|
104
|
+
fetchCreateWalletRequest: (params: { credential: string; devicePublicKey: string }) => Promise<CreateWalletResponse>
|
|
70
105
|
|
|
71
106
|
fetchWalletSigninRequest: (params: { credential: string }) => Promise<WalletSignInResponse>
|
|
72
107
|
|
|
73
|
-
|
|
74
|
-
fetchSignMessagesRequest: (params: {
|
|
75
|
-
messages: string[]
|
|
76
|
-
credential: string | undefined
|
|
77
|
-
}) => Promise<{ signatures: string[] }>
|
|
108
|
+
fetchSignMessagesRequest: (params: { messages: string[]; auth: SignAuth }) => Promise<{ signatures: string[] }>
|
|
78
109
|
|
|
79
110
|
fetchSignTransactionsRequest: (params: {
|
|
80
111
|
transactions: string[]
|
|
81
|
-
|
|
112
|
+
auth: SignAuth
|
|
82
113
|
}) => Promise<{ signatures: string[] }>
|
|
83
114
|
|
|
84
|
-
fetchSignTypedDataRequest: (params: {
|
|
85
|
-
typedDataBatch: string[]
|
|
86
|
-
credential: string | undefined
|
|
87
|
-
}) => Promise<{ signatures: string[] }>
|
|
115
|
+
fetchSignTypedDataRequest: (params: { typedDataBatch: string[]; auth: SignAuth }) => Promise<{ signatures: string[] }>
|
|
88
116
|
|
|
89
117
|
fetchDisconnectRequest: () => Promise<DisconnectResponse>
|
|
90
118
|
|
|
119
|
+
fetchListAuthenticatorsRequest: (params: {
|
|
120
|
+
credential?: string
|
|
121
|
+
walletId?: string
|
|
122
|
+
}) => Promise<ListAuthenticatorsResponse>
|
|
123
|
+
|
|
91
124
|
fetchSecuredChallengeRequest: (params: {
|
|
92
125
|
type: OldAuthenticationTypes
|
|
93
126
|
action: OldAction
|
|
@@ -99,27 +132,59 @@ export interface EmbeddedWalletApiClient {
|
|
|
99
132
|
credential: string
|
|
100
133
|
}) => Promise<ExportSeedPhraseResponse>
|
|
101
134
|
|
|
102
|
-
|
|
135
|
+
fetchStartAuthenticatedSessionRequest: (params: {
|
|
136
|
+
existingCredential: string
|
|
137
|
+
devicePublicKey: string
|
|
138
|
+
}) => Promise<StartAuthenticatedSessionResponse>
|
|
103
139
|
|
|
104
|
-
|
|
140
|
+
fetchAddAuthenticatorRequest: (params: {
|
|
105
141
|
newCredential: string
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
existingAuthenticationType: OldAuthenticationTypes
|
|
109
|
-
}) => Promise<RegisterNewAuthenticatorResponse>
|
|
142
|
+
deviceSignature: string
|
|
143
|
+
}) => Promise<AddAuthenticatorResponse>
|
|
110
144
|
|
|
111
145
|
fetchDeleteAuthenticatorRequest: (params: {
|
|
112
146
|
credential: string
|
|
113
|
-
authenticationType: OldAuthenticationTypes
|
|
114
147
|
authenticatorId: string
|
|
115
|
-
authenticatorType: string
|
|
116
148
|
}) => Promise<DeleteAuthenticatorResponse>
|
|
149
|
+
|
|
150
|
+
fetchOprfEvaluate: (params: {
|
|
151
|
+
blindedElement: string
|
|
152
|
+
isRecovery?: boolean
|
|
153
|
+
authMethodId?: string
|
|
154
|
+
}) => Promise<OprfEvaluateResponse>
|
|
155
|
+
|
|
156
|
+
fetchSetupRecovery: (params: {
|
|
157
|
+
credential: string
|
|
158
|
+
authMethodId: string
|
|
159
|
+
authMethodType?: string
|
|
160
|
+
encryptedKeyId?: string
|
|
161
|
+
authMethodIdentifier?: string
|
|
162
|
+
}) => Promise<SetupRecoveryResponse>
|
|
163
|
+
|
|
164
|
+
fetchExecuteRecovery: (params: {
|
|
165
|
+
authMethodId: string
|
|
166
|
+
newCredential: string
|
|
167
|
+
authKeySignature: string
|
|
168
|
+
recoveryAuthSignature: string
|
|
169
|
+
}) => Promise<ExecuteRecoveryResponse>
|
|
170
|
+
|
|
171
|
+
fetchReportDecryptionResult: (params: {
|
|
172
|
+
success: boolean
|
|
173
|
+
authMethodId: string
|
|
174
|
+
newPasskeyPublicKey?: string
|
|
175
|
+
}) => Promise<ReportDecryptionResultResponse>
|
|
176
|
+
|
|
177
|
+
fetchGetRecoveryConfig: (params: { authMethodId: string }) => Promise<GetRecoveryConfigResponse>
|
|
178
|
+
|
|
179
|
+
fetchDeleteRecovery: (params: { credential: string }) => Promise<DeleteRecoveryResponse>
|
|
117
180
|
}
|
|
118
181
|
|
|
119
182
|
export function createEmbeddedWalletApiClient({
|
|
120
183
|
rpcClient,
|
|
121
184
|
legacyRpcClient,
|
|
122
185
|
}: EmbeddedWalletClientContext): EmbeddedWalletApiClient {
|
|
186
|
+
const inflightRequests = new Map<string, Promise<unknown>>()
|
|
187
|
+
|
|
123
188
|
async function fetchChallengeRequest({
|
|
124
189
|
type,
|
|
125
190
|
action,
|
|
@@ -128,6 +193,10 @@ export function createEmbeddedWalletApiClient({
|
|
|
128
193
|
message,
|
|
129
194
|
transaction,
|
|
130
195
|
typedData,
|
|
196
|
+
authenticatorId,
|
|
197
|
+
devicePublicKey,
|
|
198
|
+
authPublicKey,
|
|
199
|
+
privyUserId,
|
|
131
200
|
}: {
|
|
132
201
|
type: NewAuthenticationTypes
|
|
133
202
|
action: NewAction
|
|
@@ -136,20 +205,49 @@ export function createEmbeddedWalletApiClient({
|
|
|
136
205
|
message?: string
|
|
137
206
|
transaction?: string
|
|
138
207
|
typedData?: string
|
|
208
|
+
authenticatorId?: string
|
|
209
|
+
devicePublicKey?: string
|
|
210
|
+
authPublicKey?: string
|
|
211
|
+
privyUserId?: string
|
|
139
212
|
}): Promise<ChallengeResponse> {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
213
|
+
const cacheKey = `challenge:${type}:${action}:${walletId ?? 'no-wallet'}:${message ?? ''}:${transaction ?? ''}:${typedData ?? ''}:${authenticatorId ?? ''}:${devicePublicKey ?? ''}`
|
|
214
|
+
|
|
215
|
+
const existingRequest = inflightRequests.get(cacheKey) as Promise<ChallengeResponse> | undefined
|
|
216
|
+
if (existingRequest) {
|
|
217
|
+
return existingRequest
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const request = rpcClient
|
|
221
|
+
.challenge({
|
|
222
|
+
type,
|
|
223
|
+
action,
|
|
224
|
+
options,
|
|
225
|
+
walletId,
|
|
226
|
+
message,
|
|
227
|
+
transaction,
|
|
228
|
+
typedData,
|
|
229
|
+
authenticatorId,
|
|
230
|
+
devicePublicKey,
|
|
231
|
+
authPublicKey,
|
|
232
|
+
privyUserId,
|
|
233
|
+
})
|
|
234
|
+
.finally(() => {
|
|
235
|
+
inflightRequests.delete(cacheKey)
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
inflightRequests.set(cacheKey, request)
|
|
239
|
+
|
|
240
|
+
return request
|
|
149
241
|
}
|
|
150
242
|
|
|
151
|
-
async function fetchCreateWalletRequest({
|
|
152
|
-
|
|
243
|
+
async function fetchCreateWalletRequest({
|
|
244
|
+
credential,
|
|
245
|
+
devicePublicKey,
|
|
246
|
+
}: {
|
|
247
|
+
credential: string
|
|
248
|
+
devicePublicKey: string
|
|
249
|
+
}): Promise<CreateWalletResponse> {
|
|
250
|
+
return await rpcClient.createWallet({ credential, devicePublicKey })
|
|
153
251
|
}
|
|
154
252
|
|
|
155
253
|
async function fetchWalletSigninRequest({ credential }: { credential: string }): Promise<WalletSignInResponse> {
|
|
@@ -158,10 +256,10 @@ export function createEmbeddedWalletApiClient({
|
|
|
158
256
|
|
|
159
257
|
async function fetchSignMessagesRequest({
|
|
160
258
|
messages,
|
|
161
|
-
|
|
259
|
+
auth,
|
|
162
260
|
}: {
|
|
163
261
|
messages: string[]
|
|
164
|
-
|
|
262
|
+
auth: SignAuth
|
|
165
263
|
}): Promise<{ signatures: string[] }> {
|
|
166
264
|
if (messages.length === 0) {
|
|
167
265
|
throw new Error('At least one message required')
|
|
@@ -171,17 +269,17 @@ export function createEmbeddedWalletApiClient({
|
|
|
171
269
|
}
|
|
172
270
|
const result = await rpcClient.signMessage({
|
|
173
271
|
message: messages[0],
|
|
174
|
-
|
|
272
|
+
auth,
|
|
175
273
|
})
|
|
176
274
|
return { signatures: [result.signature] }
|
|
177
275
|
}
|
|
178
276
|
|
|
179
277
|
async function fetchSignTransactionsRequest({
|
|
180
278
|
transactions,
|
|
181
|
-
|
|
279
|
+
auth,
|
|
182
280
|
}: {
|
|
183
281
|
transactions: string[]
|
|
184
|
-
|
|
282
|
+
auth: SignAuth
|
|
185
283
|
}): Promise<{ signatures: string[] }> {
|
|
186
284
|
if (transactions.length === 0) {
|
|
187
285
|
throw new Error('At least one transaction required')
|
|
@@ -191,17 +289,17 @@ export function createEmbeddedWalletApiClient({
|
|
|
191
289
|
}
|
|
192
290
|
const result = await rpcClient.signTransaction({
|
|
193
291
|
transaction: transactions[0],
|
|
194
|
-
|
|
292
|
+
auth,
|
|
195
293
|
})
|
|
196
294
|
return { signatures: [result.signature] }
|
|
197
295
|
}
|
|
198
296
|
|
|
199
297
|
async function fetchSignTypedDataRequest({
|
|
200
298
|
typedDataBatch,
|
|
201
|
-
|
|
299
|
+
auth,
|
|
202
300
|
}: {
|
|
203
301
|
typedDataBatch: string[]
|
|
204
|
-
|
|
302
|
+
auth: SignAuth
|
|
205
303
|
}): Promise<{ signatures: string[] }> {
|
|
206
304
|
if (typedDataBatch.length === 0) {
|
|
207
305
|
throw new Error('At least one typed data required')
|
|
@@ -211,7 +309,7 @@ export function createEmbeddedWalletApiClient({
|
|
|
211
309
|
}
|
|
212
310
|
const result = await rpcClient.signTypedData({
|
|
213
311
|
typedData: typedDataBatch[0],
|
|
214
|
-
|
|
312
|
+
auth,
|
|
215
313
|
})
|
|
216
314
|
return { signatures: [result.signature] }
|
|
217
315
|
}
|
|
@@ -220,6 +318,29 @@ export function createEmbeddedWalletApiClient({
|
|
|
220
318
|
return await rpcClient.disconnect({})
|
|
221
319
|
}
|
|
222
320
|
|
|
321
|
+
async function fetchListAuthenticatorsRequest({
|
|
322
|
+
credential,
|
|
323
|
+
walletId,
|
|
324
|
+
}: {
|
|
325
|
+
credential?: string
|
|
326
|
+
walletId?: string
|
|
327
|
+
}): Promise<ListAuthenticatorsResponse> {
|
|
328
|
+
const cacheKey = `listAuthenticators:${credential ?? walletId ?? 'no-key'}`
|
|
329
|
+
|
|
330
|
+
const existingRequest = inflightRequests.get(cacheKey) as Promise<ListAuthenticatorsResponse> | undefined
|
|
331
|
+
if (existingRequest) {
|
|
332
|
+
return existingRequest
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const request = rpcClient.listAuthenticators({ credential, walletId }).finally(() => {
|
|
336
|
+
inflightRequests.delete(cacheKey)
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
inflightRequests.set(cacheKey, request)
|
|
340
|
+
|
|
341
|
+
return request
|
|
342
|
+
}
|
|
343
|
+
|
|
223
344
|
async function fetchSecuredChallengeRequest({
|
|
224
345
|
type,
|
|
225
346
|
action,
|
|
@@ -253,61 +374,105 @@ export function createEmbeddedWalletApiClient({
|
|
|
253
374
|
return await legacyRpcClient.exportSeedPhrase({ credential, b64EncryptionPublicKey: encryptionKey })
|
|
254
375
|
}
|
|
255
376
|
|
|
256
|
-
async function
|
|
257
|
-
|
|
377
|
+
async function fetchStartAuthenticatedSessionRequest({
|
|
378
|
+
existingCredential,
|
|
379
|
+
devicePublicKey,
|
|
258
380
|
}: {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
return await legacyRpcClient.listAuthenticators({ credential })
|
|
381
|
+
existingCredential: string
|
|
382
|
+
devicePublicKey: string
|
|
383
|
+
}): Promise<StartAuthenticatedSessionResponse> {
|
|
384
|
+
return await rpcClient.startAuthenticatedSession({ existingCredential, devicePublicKey })
|
|
265
385
|
}
|
|
266
386
|
|
|
267
|
-
async function
|
|
387
|
+
async function fetchAddAuthenticatorRequest({
|
|
268
388
|
newCredential,
|
|
269
|
-
|
|
270
|
-
existingCredential,
|
|
271
|
-
existingAuthenticationType,
|
|
389
|
+
deviceSignature,
|
|
272
390
|
}: {
|
|
273
391
|
newCredential: string
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}): Promise<RegisterNewAuthenticatorResponse> {
|
|
278
|
-
if (!legacyRpcClient) {
|
|
279
|
-
throw new Error('RegisterNewAuthenticator not supported in new API - legacy client required')
|
|
280
|
-
}
|
|
281
|
-
return await legacyRpcClient.registerNewAuthenticator({
|
|
282
|
-
newCredential,
|
|
283
|
-
newAuthenticationType,
|
|
284
|
-
existingCredential,
|
|
285
|
-
existingAuthenticationType,
|
|
286
|
-
})
|
|
392
|
+
deviceSignature: string
|
|
393
|
+
}): Promise<AddAuthenticatorResponse> {
|
|
394
|
+
return await rpcClient.addAuthenticator({ newCredential, deviceSignature })
|
|
287
395
|
}
|
|
288
396
|
|
|
289
397
|
async function fetchDeleteAuthenticatorRequest({
|
|
290
398
|
credential,
|
|
291
|
-
authenticationType,
|
|
292
399
|
authenticatorId,
|
|
293
|
-
authenticatorType,
|
|
294
400
|
}: {
|
|
295
401
|
credential: string
|
|
296
|
-
authenticationType: OldAuthenticationTypes
|
|
297
402
|
authenticatorId: string
|
|
298
|
-
authenticatorType: string
|
|
299
403
|
}): Promise<DeleteAuthenticatorResponse> {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
404
|
+
return await rpcClient.deleteAuthenticator({ credential, authenticatorId })
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
async function fetchOprfEvaluate({
|
|
408
|
+
blindedElement,
|
|
409
|
+
isRecovery,
|
|
410
|
+
authMethodId,
|
|
411
|
+
}: {
|
|
412
|
+
blindedElement: string
|
|
413
|
+
isRecovery?: boolean
|
|
414
|
+
authMethodId?: string
|
|
415
|
+
}): Promise<OprfEvaluateResponse> {
|
|
416
|
+
return await rpcClient.oprfEvaluate({ blindedElement, isRecovery, authMethodId })
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
async function fetchSetupRecovery({
|
|
420
|
+
credential,
|
|
421
|
+
authMethodId,
|
|
422
|
+
authMethodType,
|
|
423
|
+
encryptedKeyId,
|
|
424
|
+
authMethodIdentifier,
|
|
425
|
+
}: {
|
|
426
|
+
credential: string
|
|
427
|
+
authMethodId: string
|
|
428
|
+
authMethodType?: string
|
|
429
|
+
encryptedKeyId?: string
|
|
430
|
+
authMethodIdentifier?: string
|
|
431
|
+
}): Promise<SetupRecoveryResponse> {
|
|
432
|
+
return await rpcClient.setupRecovery({
|
|
304
433
|
credential,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
434
|
+
authMethodId,
|
|
435
|
+
authMethodType,
|
|
436
|
+
encryptedKeyId,
|
|
437
|
+
authMethodIdentifier,
|
|
308
438
|
})
|
|
309
439
|
}
|
|
310
440
|
|
|
441
|
+
async function fetchExecuteRecovery({
|
|
442
|
+
authMethodId,
|
|
443
|
+
newCredential,
|
|
444
|
+
authKeySignature,
|
|
445
|
+
recoveryAuthSignature,
|
|
446
|
+
}: {
|
|
447
|
+
authMethodId: string
|
|
448
|
+
newCredential: string
|
|
449
|
+
authKeySignature: string
|
|
450
|
+
recoveryAuthSignature: string
|
|
451
|
+
}): Promise<ExecuteRecoveryResponse> {
|
|
452
|
+
return await rpcClient.executeRecovery({
|
|
453
|
+
authMethodId,
|
|
454
|
+
newCredential,
|
|
455
|
+
authKeySignature,
|
|
456
|
+
recoveryAuthSignature,
|
|
457
|
+
})
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
async function fetchReportDecryptionResult(params: {
|
|
461
|
+
success: boolean
|
|
462
|
+
authMethodId: string
|
|
463
|
+
newPasskeyPublicKey?: string
|
|
464
|
+
}): Promise<ReportDecryptionResultResponse> {
|
|
465
|
+
return await rpcClient.reportDecryptionResult(params)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
async function fetchGetRecoveryConfig(params: { authMethodId: string }): Promise<GetRecoveryConfigResponse> {
|
|
469
|
+
return await rpcClient.getRecoveryConfig(params)
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
async function fetchDeleteRecovery({ credential }: { credential: string }): Promise<DeleteRecoveryResponse> {
|
|
473
|
+
return await rpcClient.deleteRecovery({ credential })
|
|
474
|
+
}
|
|
475
|
+
|
|
311
476
|
return {
|
|
312
477
|
fetchChallengeRequest,
|
|
313
478
|
fetchSecuredChallengeRequest,
|
|
@@ -319,7 +484,14 @@ export function createEmbeddedWalletApiClient({
|
|
|
319
484
|
fetchExportSeedPhraseRequest,
|
|
320
485
|
fetchDisconnectRequest,
|
|
321
486
|
fetchListAuthenticatorsRequest,
|
|
322
|
-
|
|
487
|
+
fetchStartAuthenticatedSessionRequest,
|
|
488
|
+
fetchAddAuthenticatorRequest,
|
|
323
489
|
fetchDeleteAuthenticatorRequest,
|
|
490
|
+
fetchOprfEvaluate,
|
|
491
|
+
fetchSetupRecovery,
|
|
492
|
+
fetchExecuteRecovery,
|
|
493
|
+
fetchReportDecryptionResult,
|
|
494
|
+
fetchGetRecoveryConfig,
|
|
495
|
+
fetchDeleteRecovery,
|
|
324
496
|
}
|
|
325
497
|
}
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
WidgetUrlRequest,
|
|
19
19
|
WidgetUrlResponse,
|
|
20
20
|
} from '@uniswap/client-for/dist/for/v1/api_pb'
|
|
21
|
-
import { FetchClient } from '@
|
|
22
|
-
import { createFetcher } from '@
|
|
23
|
-
import { FORQuoteResponse } from '@
|
|
24
|
-
import { transformPaymentMethods } from '@
|
|
21
|
+
import { FetchClient } from '@universe/api/src/clients/base/types'
|
|
22
|
+
import { createFetcher } from '@universe/api/src/clients/base/utils'
|
|
23
|
+
import { FORQuoteResponse } from '@universe/api/src/clients/for/types'
|
|
24
|
+
import { transformPaymentMethods } from '@universe/api/src/clients/for/utils'
|
|
25
25
|
|
|
26
26
|
type ForApiClientContext = {
|
|
27
27
|
fetchClient: FetchClient
|
package/src/clients/for/utils.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PartialMessage } from '@bufbuild/protobuf'
|
|
2
|
+
import { type PromiseClient } from '@connectrpc/connect'
|
|
3
|
+
import { type UniRpcService } from '@uniswap/client-unirpc-v2/dist/uniswap/unirpc/v2/service_connect'
|
|
4
|
+
import type {
|
|
5
|
+
EstimateGasFeeRequest,
|
|
6
|
+
EstimateGasFeeResponse,
|
|
7
|
+
} from '@uniswap/client-unirpc-v2/dist/uniswap/unirpc/v2/service_pb'
|
|
8
|
+
|
|
9
|
+
export interface GasServiceClientContext {
|
|
10
|
+
rpcClient: PromiseClient<typeof UniRpcService>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface GasServiceClient {
|
|
14
|
+
estimateGasFee: (params: PartialMessage<EstimateGasFeeRequest>) => Promise<EstimateGasFeeResponse>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createGasServiceClient({ rpcClient }: GasServiceClientContext): GasServiceClient {
|
|
18
|
+
return {
|
|
19
|
+
estimateGasFee: (params): Promise<EstimateGasFeeResponse> => rpcClient.estimateGasFee(params),
|
|
20
|
+
}
|
|
21
|
+
}
|