@coinbase/cdp-sdk 1.47.0 → 1.48.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/CHANGELOG.md +14 -0
- package/README.md +287 -0
- package/_cjs/actions/webhooks/createWebhookSubscription.js.map +1 -1
- package/_cjs/client/cdp.js +1 -4
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/end-user/endUser.js +42 -89
- package/_cjs/client/end-user/endUser.js.map +1 -1
- package/_cjs/client/end-user/toEndUserAccount.js +17 -43
- package/_cjs/client/end-user/toEndUserAccount.js.map +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/cdpApiClient.js +0 -32
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +57 -10
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.js → embedded-wallets/embedded-wallets.js} +45 -97
- package/_cjs/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -0
- package/_cjs/openapi-client/generated/webhooks/webhooks.js +6 -6
- package/_cjs/openapi-client/index.js +2 -2
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/actions/webhooks/createWebhookSubscription.js.map +1 -1
- package/_esm/client/cdp.js +2 -5
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/end-user/endUser.js +40 -87
- package/_esm/client/end-user/endUser.js.map +1 -1
- package/_esm/client/end-user/toEndUserAccount.js +17 -43
- package/_esm/client/end-user/toEndUserAccount.js.map +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/cdpApiClient.js +0 -32
- package/_esm/openapi-client/cdpApiClient.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +55 -8
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.js → embedded-wallets/embedded-wallets.js} +43 -93
- package/_esm/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -0
- package/_esm/openapi-client/generated/webhooks/webhooks.js +6 -6
- package/_esm/openapi-client/index.js +2 -2
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/actions/webhooks/createWebhookSubscription.d.ts +1 -1
- package/_types/actions/webhooks/createWebhookSubscription.d.ts.map +1 -1
- package/_types/client/cdp.d.ts +2 -6
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/end-user/endUser.d.ts +19 -52
- package/_types/client/end-user/endUser.d.ts.map +1 -1
- package/_types/client/end-user/endUser.types.d.ts +26 -61
- package/_types/client/end-user/endUser.types.d.ts.map +1 -1
- package/_types/client/end-user/toEndUserAccount.d.ts +0 -2
- package/_types/client/end-user/toEndUserAccount.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +490 -79
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts +151 -0
- package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts.map +1 -0
- package/_types/openapi-client/generated/webhooks/webhooks.d.ts +6 -6
- package/_types/openapi-client/index.d.ts +14 -45
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/actions/webhooks/createWebhookSubscription.ts +6 -1
- package/client/cdp.ts +3 -8
- package/client/end-user/endUser.ts +85 -187
- package/client/end-user/endUser.types.ts +28 -69
- package/client/end-user/toEndUserAccount.ts +63 -152
- package/index.ts +0 -4
- package/openapi-client/cdpApiClient.ts +0 -34
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +551 -85
- package/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.ts → embedded-wallets/embedded-wallets.ts} +86 -249
- package/openapi-client/generated/webhooks/webhooks.ts +6 -6
- package/openapi-client/index.ts +2 -2
- package/package.json +1 -1
- package/version.ts +1 -1
- package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +0 -1
- package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +0 -1
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts +0 -312
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts.map +0 -1
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
AddEndUserEvmSmartAccount201,
|
|
8
8
|
AddEndUserSolanaAccount201,
|
|
9
9
|
EndUser as OpenAPIEndUser,
|
|
10
|
-
|
|
10
|
+
GetDelegationForEndUser200,
|
|
11
11
|
SignEvmTransactionWithEndUserAccount200,
|
|
12
12
|
SignEvmMessageWithEndUserAccount200,
|
|
13
13
|
SignEvmTypedDataWithEndUserAccount200,
|
|
@@ -20,7 +20,6 @@ import type {
|
|
|
20
20
|
EvmCall,
|
|
21
21
|
CreateEvmEip7702DelegationWithEndUserAccount201,
|
|
22
22
|
EvmEip7702DelegationNetwork,
|
|
23
|
-
SignSolanaHashWithEndUserAccount200,
|
|
24
23
|
SignSolanaMessageWithEndUserAccount200,
|
|
25
24
|
SignSolanaTransactionWithEndUserAccount200,
|
|
26
25
|
SendSolanaTransactionWithEndUserAccount200,
|
|
@@ -142,33 +141,31 @@ export interface ImportEndUserOptions {
|
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
/**
|
|
145
|
-
* The options for
|
|
144
|
+
* The options for getting the active delegation for an end user.
|
|
146
145
|
*/
|
|
147
|
-
export interface
|
|
146
|
+
export interface GetDelegationForEndUserOptions {
|
|
148
147
|
/**
|
|
149
148
|
* The unique identifier of the end user.
|
|
150
149
|
*/
|
|
151
150
|
userId: string;
|
|
152
151
|
}
|
|
153
152
|
|
|
154
|
-
|
|
153
|
+
/**
|
|
154
|
+
* The result of getting the active delegation for an end user.
|
|
155
|
+
*/
|
|
156
|
+
export type GetDelegationForEndUserResult = GetDelegationForEndUser200;
|
|
155
157
|
|
|
156
158
|
/**
|
|
157
|
-
* The options for
|
|
159
|
+
* The options for revoking all active delegations for an end user.
|
|
158
160
|
*/
|
|
159
|
-
export interface
|
|
160
|
-
/**
|
|
161
|
+
export interface RevokeDelegationForEndUserOptions {
|
|
162
|
+
/**
|
|
163
|
+
* The unique identifier of the end user.
|
|
164
|
+
*/
|
|
161
165
|
userId: string;
|
|
162
|
-
/** The 32-byte hash to sign, hex-encoded. */
|
|
163
|
-
hash: string;
|
|
164
|
-
/** The EVM address to sign with. */
|
|
165
|
-
address: string;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
* The result of signing an EVM hash on behalf of an end user.
|
|
170
|
-
*/
|
|
171
|
-
export type SignEvmHashResult = SignEvmHashWithEndUserAccount200;
|
|
168
|
+
// ─── EVM Sign Options/Results ───
|
|
172
169
|
|
|
173
170
|
/**
|
|
174
171
|
* The options for signing an EVM transaction on behalf of an end user.
|
|
@@ -318,23 +315,6 @@ export type CreateEvmEip7702DelegationForEndUserResult =
|
|
|
318
315
|
|
|
319
316
|
// ─── Solana Sign Options/Results ───
|
|
320
317
|
|
|
321
|
-
/**
|
|
322
|
-
* The options for signing a Solana hash on behalf of an end user.
|
|
323
|
-
*/
|
|
324
|
-
export interface SignSolanaHashOptions {
|
|
325
|
-
/** The unique identifier of the end user. */
|
|
326
|
-
userId: string;
|
|
327
|
-
/** The 32-byte hash to sign. */
|
|
328
|
-
hash: string;
|
|
329
|
-
/** The Solana address to sign with. */
|
|
330
|
-
address: string;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* The result of signing a Solana hash on behalf of an end user.
|
|
335
|
-
*/
|
|
336
|
-
export type SignSolanaHashResult = SignSolanaHashWithEndUserAccount200;
|
|
337
|
-
|
|
338
318
|
/**
|
|
339
319
|
* The options for signing a Solana message on behalf of an end user.
|
|
340
320
|
*/
|
|
@@ -417,16 +397,6 @@ export type SendSolanaAssetResult = SendSolanaAssetWithEndUserAccount200;
|
|
|
417
397
|
|
|
418
398
|
// ─── EndUserAccount Action Method Options (address optional, userId auto-bound) ───
|
|
419
399
|
|
|
420
|
-
/**
|
|
421
|
-
* The options for signing an EVM hash on an EndUser object.
|
|
422
|
-
*/
|
|
423
|
-
export interface AccountSignEvmHashOptions {
|
|
424
|
-
/** The 32-byte hash to sign, hex-encoded. */
|
|
425
|
-
hash: string;
|
|
426
|
-
/** The EVM address to sign with. Uses the first EVM account if not provided. */
|
|
427
|
-
address?: string;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
400
|
/**
|
|
431
401
|
* The options for signing an EVM transaction on an EndUser object.
|
|
432
402
|
*/
|
|
@@ -519,16 +489,6 @@ export interface AccountCreateEvmEip7702DelegationOptions {
|
|
|
519
489
|
enableSpendPermissions?: boolean;
|
|
520
490
|
}
|
|
521
491
|
|
|
522
|
-
/**
|
|
523
|
-
* The options for signing a Solana hash on an EndUser object.
|
|
524
|
-
*/
|
|
525
|
-
export interface AccountSignSolanaHashOptions {
|
|
526
|
-
/** The 32-byte hash to sign. */
|
|
527
|
-
hash: string;
|
|
528
|
-
/** The Solana address to sign with. Uses the first Solana account if not provided. */
|
|
529
|
-
address?: string;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
492
|
/**
|
|
533
493
|
* The options for signing a Solana message on an EndUser object.
|
|
534
494
|
*/
|
|
@@ -651,6 +611,21 @@ export type EndUserAccountActions = {
|
|
|
651
611
|
*/
|
|
652
612
|
addSolanaAccount: () => Promise<AddEndUserSolanaAccountResult>;
|
|
653
613
|
|
|
614
|
+
/**
|
|
615
|
+
* Gets the active delegation for this end user, if one exists.
|
|
616
|
+
*
|
|
617
|
+
* @returns A promise that resolves to the delegation details including its expiry.
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```ts
|
|
621
|
+
* const endUser = await cdp.endUser.getEndUser({ userId: "user-123" });
|
|
622
|
+
*
|
|
623
|
+
* const delegation = await endUser.getDelegation();
|
|
624
|
+
* console.log(delegation.expiresAt);
|
|
625
|
+
* ```
|
|
626
|
+
*/
|
|
627
|
+
getDelegation: () => Promise<GetDelegationForEndUserResult>;
|
|
628
|
+
|
|
654
629
|
/**
|
|
655
630
|
* Revokes all active delegations for this end user.
|
|
656
631
|
* This operation can be performed by the end user themselves or by a developer using their API key.
|
|
@@ -668,14 +643,6 @@ export type EndUserAccountActions = {
|
|
|
668
643
|
|
|
669
644
|
// ─── Delegated EVM Sign Methods ───
|
|
670
645
|
|
|
671
|
-
/**
|
|
672
|
-
* Signs an EVM hash on behalf of this end user using a delegation.
|
|
673
|
-
*
|
|
674
|
-
* @param options - The signing options.
|
|
675
|
-
* @returns A promise that resolves to the signature.
|
|
676
|
-
*/
|
|
677
|
-
signEvmHash: (options: AccountSignEvmHashOptions) => Promise<SignEvmHashResult>;
|
|
678
|
-
|
|
679
646
|
/**
|
|
680
647
|
* Signs an EVM transaction on behalf of this end user using a delegation.
|
|
681
648
|
*
|
|
@@ -744,14 +711,6 @@ export type EndUserAccountActions = {
|
|
|
744
711
|
|
|
745
712
|
// ─── Delegated Solana Sign Methods ───
|
|
746
713
|
|
|
747
|
-
/**
|
|
748
|
-
* Signs a Solana hash on behalf of this end user using a delegation.
|
|
749
|
-
*
|
|
750
|
-
* @param options - The signing options.
|
|
751
|
-
* @returns A promise that resolves to the signature.
|
|
752
|
-
*/
|
|
753
|
-
signSolanaHash: (options: AccountSignSolanaHashOptions) => Promise<SignSolanaHashResult>;
|
|
754
|
-
|
|
755
714
|
/**
|
|
756
715
|
* Signs a Solana message on behalf of this end user using a delegation.
|
|
757
716
|
*
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
AddEndUserEvmSmartAccountResult,
|
|
7
7
|
AddEndUserSolanaAccountResult,
|
|
8
8
|
AddEvmSmartAccountOptions,
|
|
9
|
-
|
|
9
|
+
GetDelegationForEndUserResult,
|
|
10
10
|
SignEvmTransactionResult,
|
|
11
11
|
SignEvmMessageResult,
|
|
12
12
|
SignEvmTypedDataResult,
|
|
@@ -14,12 +14,10 @@ import type {
|
|
|
14
14
|
SendEvmAssetResult,
|
|
15
15
|
SendUserOperationResult,
|
|
16
16
|
CreateEvmEip7702DelegationForEndUserResult,
|
|
17
|
-
SignSolanaHashResult,
|
|
18
17
|
SignSolanaMessageResult,
|
|
19
18
|
SignSolanaTransactionResult,
|
|
20
19
|
SendSolanaTransactionResult,
|
|
21
20
|
SendSolanaAssetResult,
|
|
22
|
-
AccountSignEvmHashOptions,
|
|
23
21
|
AccountSignEvmTransactionOptions,
|
|
24
22
|
AccountSignEvmMessageOptions,
|
|
25
23
|
AccountSignEvmTypedDataOptions,
|
|
@@ -27,7 +25,6 @@ import type {
|
|
|
27
25
|
AccountSendEvmAssetOptions,
|
|
28
26
|
AccountSendUserOperationOptions,
|
|
29
27
|
AccountCreateEvmEip7702DelegationOptions,
|
|
30
|
-
AccountSignSolanaHashOptions,
|
|
31
28
|
AccountSignSolanaMessageOptions,
|
|
32
29
|
AccountSignSolanaTransactionOptions,
|
|
33
30
|
AccountSendSolanaTransactionOptions,
|
|
@@ -44,28 +41,8 @@ import type {
|
|
|
44
41
|
export type ToEndUserAccountOptions = {
|
|
45
42
|
/** The end user from the API response. */
|
|
46
43
|
endUser: OpenAPIEndUser;
|
|
47
|
-
/** The CDP project ID. Required for delegation operations (signing, sending). */
|
|
48
|
-
projectId?: string;
|
|
49
44
|
};
|
|
50
45
|
|
|
51
|
-
/**
|
|
52
|
-
* Returns the project ID or throws if not configured.
|
|
53
|
-
* Used by delegation operations that require a project ID.
|
|
54
|
-
*
|
|
55
|
-
* @param projectId - The project ID to validate.
|
|
56
|
-
* @returns The validated project ID.
|
|
57
|
-
*/
|
|
58
|
-
function requireProjectId(projectId: string | undefined): string {
|
|
59
|
-
if (!projectId) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
"Missing required project ID for delegation operation. " +
|
|
62
|
-
"Set the CDP_PROJECT_ID environment variable or pass projectId to the CdpClient constructor.",
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return projectId;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
46
|
/**
|
|
70
47
|
* Resolves the first EVM EOA address for this end user, or throws if none exist and no override was provided.
|
|
71
48
|
*
|
|
@@ -131,7 +108,7 @@ export function toEndUserAccount(
|
|
|
131
108
|
apiClient: CdpOpenApiClientType,
|
|
132
109
|
options: ToEndUserAccountOptions,
|
|
133
110
|
): EndUserAccount {
|
|
134
|
-
const { endUser
|
|
111
|
+
const { endUser } = options;
|
|
135
112
|
|
|
136
113
|
const endUserAccount: EndUserAccount = {
|
|
137
114
|
// Pass through all properties from the OpenAPI EndUser
|
|
@@ -167,61 +144,45 @@ export function toEndUserAccount(
|
|
|
167
144
|
return apiClient.addEndUserSolanaAccount(endUser.userId, {});
|
|
168
145
|
},
|
|
169
146
|
|
|
147
|
+
async getDelegation(): Promise<GetDelegationForEndUserResult> {
|
|
148
|
+
Analytics.trackAction({ action: "end_user_get_delegation" });
|
|
149
|
+
return apiClient.getDelegationForEndUser(endUser.userId);
|
|
150
|
+
},
|
|
151
|
+
|
|
170
152
|
async revokeDelegation(): Promise<void> {
|
|
171
153
|
Analytics.trackAction({ action: "end_user_revoke_delegation" });
|
|
172
|
-
await apiClient.revokeDelegationForEndUser(
|
|
154
|
+
await apiClient.revokeDelegationForEndUser(endUser.userId, {});
|
|
173
155
|
},
|
|
174
156
|
|
|
175
157
|
// ─── Delegated EVM Sign Methods ───
|
|
176
158
|
|
|
177
|
-
async signEvmHash(opts: AccountSignEvmHashOptions): Promise<SignEvmHashResult> {
|
|
178
|
-
Analytics.trackAction({ action: "end_user_sign_evm_hash" });
|
|
179
|
-
const address = resolveEvmAddress(endUser, opts.address);
|
|
180
|
-
return apiClient.signEvmHashWithEndUserAccount(requireProjectId(projectId), endUser.userId, {
|
|
181
|
-
hash: opts.hash,
|
|
182
|
-
address,
|
|
183
|
-
});
|
|
184
|
-
},
|
|
185
|
-
|
|
186
159
|
async signEvmTransaction(
|
|
187
160
|
opts: AccountSignEvmTransactionOptions,
|
|
188
161
|
): Promise<SignEvmTransactionResult> {
|
|
189
162
|
Analytics.trackAction({ action: "end_user_sign_evm_transaction" });
|
|
190
163
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
191
|
-
return apiClient.signEvmTransactionWithEndUserAccount(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
address,
|
|
196
|
-
transaction: opts.transaction,
|
|
197
|
-
},
|
|
198
|
-
);
|
|
164
|
+
return apiClient.signEvmTransactionWithEndUserAccount(endUser.userId, {
|
|
165
|
+
address,
|
|
166
|
+
transaction: opts.transaction,
|
|
167
|
+
});
|
|
199
168
|
},
|
|
200
169
|
|
|
201
170
|
async signEvmMessage(opts: AccountSignEvmMessageOptions): Promise<SignEvmMessageResult> {
|
|
202
171
|
Analytics.trackAction({ action: "end_user_sign_evm_message" });
|
|
203
172
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
204
|
-
return apiClient.signEvmMessageWithEndUserAccount(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
address,
|
|
209
|
-
message: opts.message,
|
|
210
|
-
},
|
|
211
|
-
);
|
|
173
|
+
return apiClient.signEvmMessageWithEndUserAccount(endUser.userId, {
|
|
174
|
+
address,
|
|
175
|
+
message: opts.message,
|
|
176
|
+
});
|
|
212
177
|
},
|
|
213
178
|
|
|
214
179
|
async signEvmTypedData(opts: AccountSignEvmTypedDataOptions): Promise<SignEvmTypedDataResult> {
|
|
215
180
|
Analytics.trackAction({ action: "end_user_sign_evm_typed_data" });
|
|
216
181
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
217
|
-
return apiClient.signEvmTypedDataWithEndUserAccount(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
address,
|
|
222
|
-
typedData: opts.typedData,
|
|
223
|
-
},
|
|
224
|
-
);
|
|
182
|
+
return apiClient.signEvmTypedDataWithEndUserAccount(endUser.userId, {
|
|
183
|
+
address,
|
|
184
|
+
typedData: opts.typedData,
|
|
185
|
+
});
|
|
225
186
|
},
|
|
226
187
|
|
|
227
188
|
// ─── Delegated EVM Send Methods ───
|
|
@@ -231,34 +192,24 @@ export function toEndUserAccount(
|
|
|
231
192
|
): Promise<SendEvmTransactionResult> {
|
|
232
193
|
Analytics.trackAction({ action: "end_user_send_evm_transaction" });
|
|
233
194
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
234
|
-
return apiClient.sendEvmTransactionWithEndUserAccount(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
transaction: opts.transaction,
|
|
240
|
-
network: opts.network,
|
|
241
|
-
},
|
|
242
|
-
);
|
|
195
|
+
return apiClient.sendEvmTransactionWithEndUserAccount(endUser.userId, {
|
|
196
|
+
address,
|
|
197
|
+
transaction: opts.transaction,
|
|
198
|
+
network: opts.network,
|
|
199
|
+
});
|
|
243
200
|
},
|
|
244
201
|
|
|
245
202
|
async sendEvmAsset(opts: AccountSendEvmAssetOptions): Promise<SendEvmAssetResult> {
|
|
246
203
|
Analytics.trackAction({ action: "end_user_send_evm_asset" });
|
|
247
204
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
248
205
|
const asset = opts.asset ?? "usdc";
|
|
249
|
-
return apiClient.sendEvmAssetWithEndUserAccount(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
amount: opts.amount,
|
|
257
|
-
network: opts.network,
|
|
258
|
-
useCdpPaymaster: opts.useCdpPaymaster,
|
|
259
|
-
paymasterUrl: opts.paymasterUrl,
|
|
260
|
-
},
|
|
261
|
-
);
|
|
206
|
+
return apiClient.sendEvmAssetWithEndUserAccount(endUser.userId, address, asset, {
|
|
207
|
+
to: opts.to,
|
|
208
|
+
amount: opts.amount,
|
|
209
|
+
network: opts.network,
|
|
210
|
+
useCdpPaymaster: opts.useCdpPaymaster,
|
|
211
|
+
paymasterUrl: opts.paymasterUrl,
|
|
212
|
+
});
|
|
262
213
|
},
|
|
263
214
|
|
|
264
215
|
async sendUserOperation(
|
|
@@ -266,18 +217,13 @@ export function toEndUserAccount(
|
|
|
266
217
|
): Promise<SendUserOperationResult> {
|
|
267
218
|
Analytics.trackAction({ action: "end_user_send_user_operation" });
|
|
268
219
|
const address = resolveEvmSmartAccountAddress(endUser, opts.address);
|
|
269
|
-
return apiClient.sendUserOperationWithEndUserAccount(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
useCdpPaymaster: opts.useCdpPaymaster,
|
|
277
|
-
paymasterUrl: opts.paymasterUrl,
|
|
278
|
-
dataSuffix: opts.dataSuffix,
|
|
279
|
-
},
|
|
280
|
-
);
|
|
220
|
+
return apiClient.sendUserOperationWithEndUserAccount(endUser.userId, address, {
|
|
221
|
+
network: opts.network,
|
|
222
|
+
calls: opts.calls,
|
|
223
|
+
useCdpPaymaster: opts.useCdpPaymaster,
|
|
224
|
+
paymasterUrl: opts.paymasterUrl,
|
|
225
|
+
dataSuffix: opts.dataSuffix,
|
|
226
|
+
});
|
|
281
227
|
},
|
|
282
228
|
|
|
283
229
|
// ─── Delegated EVM EIP-7702 Delegation Method ───
|
|
@@ -287,45 +233,24 @@ export function toEndUserAccount(
|
|
|
287
233
|
): Promise<CreateEvmEip7702DelegationForEndUserResult> {
|
|
288
234
|
Analytics.trackAction({ action: "end_user_create_evm_eip7702_delegation" });
|
|
289
235
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
290
|
-
return apiClient.createEvmEip7702DelegationWithEndUserAccount(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
network: opts.network,
|
|
296
|
-
enableSpendPermissions: opts.enableSpendPermissions,
|
|
297
|
-
},
|
|
298
|
-
);
|
|
236
|
+
return apiClient.createEvmEip7702DelegationWithEndUserAccount(endUser.userId, {
|
|
237
|
+
address,
|
|
238
|
+
network: opts.network,
|
|
239
|
+
enableSpendPermissions: opts.enableSpendPermissions,
|
|
240
|
+
});
|
|
299
241
|
},
|
|
300
242
|
|
|
301
243
|
// ─── Delegated Solana Sign Methods ───
|
|
302
244
|
|
|
303
|
-
async signSolanaHash(opts: AccountSignSolanaHashOptions): Promise<SignSolanaHashResult> {
|
|
304
|
-
Analytics.trackAction({ action: "end_user_sign_solana_hash" });
|
|
305
|
-
const address = resolveSolanaAddress(endUser, opts.address);
|
|
306
|
-
return apiClient.signSolanaHashWithEndUserAccount(
|
|
307
|
-
requireProjectId(projectId),
|
|
308
|
-
endUser.userId,
|
|
309
|
-
{
|
|
310
|
-
hash: opts.hash,
|
|
311
|
-
address,
|
|
312
|
-
},
|
|
313
|
-
);
|
|
314
|
-
},
|
|
315
|
-
|
|
316
245
|
async signSolanaMessage(
|
|
317
246
|
opts: AccountSignSolanaMessageOptions,
|
|
318
247
|
): Promise<SignSolanaMessageResult> {
|
|
319
248
|
Analytics.trackAction({ action: "end_user_sign_solana_message" });
|
|
320
249
|
const address = resolveSolanaAddress(endUser, opts.address);
|
|
321
|
-
return apiClient.signSolanaMessageWithEndUserAccount(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
address,
|
|
326
|
-
message: opts.message,
|
|
327
|
-
},
|
|
328
|
-
);
|
|
250
|
+
return apiClient.signSolanaMessageWithEndUserAccount(endUser.userId, {
|
|
251
|
+
address,
|
|
252
|
+
message: opts.message,
|
|
253
|
+
});
|
|
329
254
|
},
|
|
330
255
|
|
|
331
256
|
async signSolanaTransaction(
|
|
@@ -333,14 +258,10 @@ export function toEndUserAccount(
|
|
|
333
258
|
): Promise<SignSolanaTransactionResult> {
|
|
334
259
|
Analytics.trackAction({ action: "end_user_sign_solana_transaction" });
|
|
335
260
|
const address = resolveSolanaAddress(endUser, opts.address);
|
|
336
|
-
return apiClient.signSolanaTransactionWithEndUserAccount(
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
address,
|
|
341
|
-
transaction: opts.transaction,
|
|
342
|
-
},
|
|
343
|
-
);
|
|
261
|
+
return apiClient.signSolanaTransactionWithEndUserAccount(endUser.userId, {
|
|
262
|
+
address,
|
|
263
|
+
transaction: opts.transaction,
|
|
264
|
+
});
|
|
344
265
|
},
|
|
345
266
|
|
|
346
267
|
// ─── Delegated Solana Send Methods ───
|
|
@@ -350,33 +271,23 @@ export function toEndUserAccount(
|
|
|
350
271
|
): Promise<SendSolanaTransactionResult> {
|
|
351
272
|
Analytics.trackAction({ action: "end_user_send_solana_transaction" });
|
|
352
273
|
const address = resolveSolanaAddress(endUser, opts.address);
|
|
353
|
-
return apiClient.sendSolanaTransactionWithEndUserAccount(
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
transaction: opts.transaction,
|
|
359
|
-
network: opts.network,
|
|
360
|
-
},
|
|
361
|
-
);
|
|
274
|
+
return apiClient.sendSolanaTransactionWithEndUserAccount(endUser.userId, {
|
|
275
|
+
address,
|
|
276
|
+
transaction: opts.transaction,
|
|
277
|
+
network: opts.network,
|
|
278
|
+
});
|
|
362
279
|
},
|
|
363
280
|
|
|
364
281
|
async sendSolanaAsset(opts: AccountSendSolanaAssetOptions): Promise<SendSolanaAssetResult> {
|
|
365
282
|
Analytics.trackAction({ action: "end_user_send_solana_asset" });
|
|
366
283
|
const address = resolveSolanaAddress(endUser, opts.address);
|
|
367
284
|
const asset = opts.asset ?? "usdc";
|
|
368
|
-
return apiClient.sendSolanaAssetWithEndUserAccount(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
to: opts.to,
|
|
375
|
-
amount: opts.amount,
|
|
376
|
-
network: opts.network,
|
|
377
|
-
createRecipientAta: opts.createRecipientAta,
|
|
378
|
-
},
|
|
379
|
-
);
|
|
285
|
+
return apiClient.sendSolanaAssetWithEndUserAccount(endUser.userId, address, asset, {
|
|
286
|
+
to: opts.to,
|
|
287
|
+
amount: opts.amount,
|
|
288
|
+
network: opts.network,
|
|
289
|
+
createRecipientAta: opts.createRecipientAta,
|
|
290
|
+
});
|
|
380
291
|
},
|
|
381
292
|
};
|
|
382
293
|
|
package/index.ts
CHANGED
|
@@ -19,8 +19,6 @@ export type {
|
|
|
19
19
|
ListEndUsersOptions,
|
|
20
20
|
EndUserAccount,
|
|
21
21
|
RevokeDelegationForEndUserOptions,
|
|
22
|
-
SignEvmHashOptions,
|
|
23
|
-
SignEvmHashResult,
|
|
24
22
|
SignEvmTransactionOptions,
|
|
25
23
|
SignEvmTransactionResult,
|
|
26
24
|
SignEvmMessageOptions,
|
|
@@ -35,8 +33,6 @@ export type {
|
|
|
35
33
|
SendUserOperationResult,
|
|
36
34
|
CreateEvmEip7702DelegationOptions as CreateEvmEip7702DelegationForEndUserOptions,
|
|
37
35
|
CreateEvmEip7702DelegationForEndUserResult,
|
|
38
|
-
SignSolanaHashOptions,
|
|
39
|
-
SignSolanaHashResult,
|
|
40
36
|
SignSolanaMessageOptions,
|
|
41
37
|
SignSolanaMessageResult,
|
|
42
38
|
SignSolanaTransactionOptions,
|
|
@@ -85,26 +85,6 @@ export const configure = (options: CdpOptions) => {
|
|
|
85
85
|
expiresIn: options.expiresIn,
|
|
86
86
|
debug: options.debugging,
|
|
87
87
|
});
|
|
88
|
-
|
|
89
|
-
/*
|
|
90
|
-
* Delegated routing interceptor.
|
|
91
|
-
* Embedded Wallet API's are exposed to the developer for delegated signing
|
|
92
|
-
* via the /delegated path, which properly forwards the Authorization and
|
|
93
|
-
* X-Wallet-Auth headers from the edge.
|
|
94
|
-
*
|
|
95
|
-
* Registered after withAuth so it runs BEFORE the auth interceptor (LIFO order).
|
|
96
|
-
* This rewrites the URL first, then the auth interceptor computes JWT headers
|
|
97
|
-
* (Authorization and X-Wallet-Auth) against the rewritten URL path, ensuring
|
|
98
|
-
* the `uris` claim matches the actual request URL.
|
|
99
|
-
* The API gateway validates the JWT, strips the /delegated prefix, and forwards
|
|
100
|
-
* to the backend.
|
|
101
|
-
*/
|
|
102
|
-
axiosInstance.interceptors.request.use(config => {
|
|
103
|
-
if (config.url && isDelegatedEndUserPath(config.url)) {
|
|
104
|
-
config.url = `/delegated${config.url}`;
|
|
105
|
-
}
|
|
106
|
-
return config;
|
|
107
|
-
});
|
|
108
88
|
};
|
|
109
89
|
|
|
110
90
|
/**
|
|
@@ -327,20 +307,6 @@ export const cdpApiClient = async <T>(
|
|
|
327
307
|
}
|
|
328
308
|
};
|
|
329
309
|
|
|
330
|
-
/**
|
|
331
|
-
* Checks if the given request URL is a delegated end-user operation that should
|
|
332
|
-
* be routed through the /platform/delegated gateway prefix.
|
|
333
|
-
*
|
|
334
|
-
* These endpoints require both Authorization and X-Wallet-Auth headers to be
|
|
335
|
-
* forwarded by the API gateway, which the /delegated prefix enables.
|
|
336
|
-
*
|
|
337
|
-
* @param url - The request URL (relative, without base path).
|
|
338
|
-
* @returns True if the path should be routed through /platform/delegated.
|
|
339
|
-
*/
|
|
340
|
-
const isDelegatedEndUserPath = (url: string): boolean => {
|
|
341
|
-
return /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/end-users\//.test(url);
|
|
342
|
-
};
|
|
343
|
-
|
|
344
310
|
/**
|
|
345
311
|
* Validates the call to the cdpApiClient.
|
|
346
312
|
*
|