@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../openapi-client/index.ts"],"names":[],"mappings":"AAAA,cAAc,sDAAsD,CAAC;AACrE,cAAc,0CAA0C,CAAC;AACzD,cAAc,sDAAsD,CAAC;AACrE,cAAc,oCAAoC,CAAC;AACnD,cAAc,sDAAsD,CAAC;AACrE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4DAA4D,CAAC;AAC3E,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0CAA0C,CAAC;AACzD,cAAc,oDAAoD,CAAC;AACnE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../openapi-client/index.ts"],"names":[],"mappings":"AAAA,cAAc,sDAAsD,CAAC;AACrE,cAAc,0CAA0C,CAAC;AACzD,cAAc,sDAAsD,CAAC;AACrE,cAAc,oCAAoC,CAAC;AACnD,cAAc,sDAAsD,CAAC;AACrE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4DAA4D,CAAC;AAC3E,cAAc,gCAAgC,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,4BAAgE;0BAAic,eAAkB,EAAC,+GAAmD,EAAC,4BAAyE;gCAA8e,YAAe,EAAC,2HAA+D,EAAC,4BAA+E;4BAAk4B,eAAkB,EAAC,mHAAuD,EAAC,4BAA2E;wBAAijB,eAAkB,EAAC,2GAA+C,EAAC,4BAAuE;4BAAwhD,mHAAuD,EAAC,4BAA2E;CAR9hL,CAAC;AAEF,eAAO,MAAM,sBAAsB;mBA9CL,0FAA8B,EAAC,4BACA;mBAKb,iGAC5B,EAAC,4BAAyD;oBAKzD,gBAAkB,EAAC,4BACf;mBASnB,gBACI,EAAC,4BAGE;mBAiB6B,gBAGrC,EAAE,iGACJ,EAAC,4BAGsC;CAFzC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,gBAAgB,CAAC;AAC3D,cAAc,gCAAgC,CAAC"}
|
package/_types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.48.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -10,7 +10,12 @@ export type WebhookEventType =
|
|
|
10
10
|
| "wallet.transaction.replaced"
|
|
11
11
|
| "wallet.transaction.confirmed"
|
|
12
12
|
| "wallet.transaction.failed"
|
|
13
|
-
| "wallet.transaction.signed"
|
|
13
|
+
| "wallet.transaction.signed"
|
|
14
|
+
| "wallet.typed_data.signed"
|
|
15
|
+
| "wallet.message.signed"
|
|
16
|
+
| "wallet.hash.signed"
|
|
17
|
+
| "wallet.delegation.created"
|
|
18
|
+
| "wallet.delegation.revoked";
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
* Options for creating a webhook subscription.
|
package/client/cdp.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Analytics } from "../analytics.js";
|
|
2
2
|
import { CdpOpenApiClient } from "../openapi-client/index.js";
|
|
3
3
|
import { version } from "../version.js";
|
|
4
|
-
import {
|
|
4
|
+
import { EndUserClient } from "./end-user/endUser.js";
|
|
5
5
|
import { EvmClient } from "./evm/evm.js";
|
|
6
6
|
import { PoliciesClient } from "./policies/policies.js";
|
|
7
7
|
import { SolanaClient } from "./solana/solana.js";
|
|
@@ -14,8 +14,6 @@ export interface CdpClientOptions {
|
|
|
14
14
|
apiKeySecret?: string;
|
|
15
15
|
/** The wallet secret. */
|
|
16
16
|
walletSecret?: string;
|
|
17
|
-
/** The CDP project ID. Required for end-user delegation operations (signing, sending). */
|
|
18
|
-
projectId?: string;
|
|
19
17
|
/** Whether to enable debugging. */
|
|
20
18
|
debugging?: boolean;
|
|
21
19
|
/** The host URL to connect to. */
|
|
@@ -36,7 +34,7 @@ export class CdpClient {
|
|
|
36
34
|
public policies: PoliciesClient;
|
|
37
35
|
|
|
38
36
|
/** Namespace containing all end user methods. */
|
|
39
|
-
public endUser:
|
|
37
|
+
public endUser: EndUserClient;
|
|
40
38
|
|
|
41
39
|
/** Namespace containing all webhook methods. */
|
|
42
40
|
public webhooks: WebhooksClient;
|
|
@@ -56,7 +54,6 @@ export class CdpClient {
|
|
|
56
54
|
* CDP_API_KEY_ID=your-api-key-id
|
|
57
55
|
* CDP_API_KEY_SECRET=your-api-key-secret
|
|
58
56
|
* CDP_WALLET_SECRET=your-wallet-secret
|
|
59
|
-
* CDP_PROJECT_ID=your-project-id
|
|
60
57
|
* ```
|
|
61
58
|
*
|
|
62
59
|
* Or passed as options to the constructor:
|
|
@@ -66,7 +63,6 @@ export class CdpClient {
|
|
|
66
63
|
* apiKeyId: "your-api-key-id",
|
|
67
64
|
* apiKeySecret: "your-api-key-secret",
|
|
68
65
|
* walletSecret: "your-wallet-secret",
|
|
69
|
-
* projectId: "your-project-id",
|
|
70
66
|
* });
|
|
71
67
|
* ```
|
|
72
68
|
*
|
|
@@ -91,7 +87,6 @@ We recommend using https://github.com/Schniz/fnm for managing your Node.js versi
|
|
|
91
87
|
const apiKeyId = options.apiKeyId ?? process.env.CDP_API_KEY_ID ?? process.env.CDP_API_KEY_NAME;
|
|
92
88
|
const apiKeySecret = options.apiKeySecret ?? process.env.CDP_API_KEY_SECRET;
|
|
93
89
|
const walletSecret = options.walletSecret ?? process.env.CDP_WALLET_SECRET;
|
|
94
|
-
const projectId = options.projectId ?? process.env.CDP_PROJECT_ID;
|
|
95
90
|
|
|
96
91
|
if (!apiKeyId || !apiKeySecret) {
|
|
97
92
|
throw new Error(`
|
|
@@ -144,7 +139,7 @@ For more information, see: https://github.com/coinbase/cdp-sdk/blob/main/typescr
|
|
|
144
139
|
this.evm = new EvmClient();
|
|
145
140
|
this.solana = new SolanaClient();
|
|
146
141
|
this.policies = new PoliciesClient();
|
|
147
|
-
this.endUser = new
|
|
142
|
+
this.endUser = new EndUserClient();
|
|
148
143
|
this.webhooks = new WebhooksClient();
|
|
149
144
|
}
|
|
150
145
|
}
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
type AddEndUserEvmSmartAccountResult,
|
|
15
15
|
type AddEndUserSolanaAccountOptions,
|
|
16
16
|
type AddEndUserSolanaAccountResult,
|
|
17
|
+
type GetDelegationForEndUserOptions,
|
|
18
|
+
type GetDelegationForEndUserResult,
|
|
17
19
|
type RevokeDelegationForEndUserOptions,
|
|
18
|
-
type SignEvmHashOptions,
|
|
19
|
-
type SignEvmHashResult,
|
|
20
20
|
type SignEvmTransactionOptions,
|
|
21
21
|
type SignEvmTransactionResult,
|
|
22
22
|
type SignEvmMessageOptions,
|
|
@@ -31,8 +31,6 @@ import {
|
|
|
31
31
|
type SendUserOperationResult,
|
|
32
32
|
type CreateEvmEip7702DelegationOptions,
|
|
33
33
|
type CreateEvmEip7702DelegationForEndUserResult,
|
|
34
|
-
type SignSolanaHashOptions,
|
|
35
|
-
type SignSolanaHashResult,
|
|
36
34
|
type SignSolanaMessageOptions,
|
|
37
35
|
type SignSolanaMessageResult,
|
|
38
36
|
type SignSolanaTransactionOptions,
|
|
@@ -52,18 +50,7 @@ import { CdpOpenApiClient, type ListEndUsers200 } from "../../openapi-client/ind
|
|
|
52
50
|
/**
|
|
53
51
|
* The CDP end user client.
|
|
54
52
|
*/
|
|
55
|
-
export class
|
|
56
|
-
private projectId?: string;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Creates a new CDPEndUserClient.
|
|
60
|
-
*
|
|
61
|
-
* @param projectId - The CDP project ID. Required for delegation operations (signing, sending).
|
|
62
|
-
*/
|
|
63
|
-
constructor(projectId?: string) {
|
|
64
|
-
this.projectId = projectId;
|
|
65
|
-
}
|
|
66
|
-
|
|
53
|
+
export class EndUserClient {
|
|
67
54
|
/**
|
|
68
55
|
* Creates an end user. An end user is an entity that can own CDP EVM accounts,
|
|
69
56
|
* EVM smart accounts, and/or Solana accounts.
|
|
@@ -104,7 +91,7 @@ export class CDPEndUserClient {
|
|
|
104
91
|
userId,
|
|
105
92
|
});
|
|
106
93
|
|
|
107
|
-
return toEndUserAccount(CdpOpenApiClient, { endUser
|
|
94
|
+
return toEndUserAccount(CdpOpenApiClient, { endUser });
|
|
108
95
|
}
|
|
109
96
|
|
|
110
97
|
/**
|
|
@@ -177,7 +164,7 @@ export class CDPEndUserClient {
|
|
|
177
164
|
|
|
178
165
|
const endUser = await CdpOpenApiClient.getEndUser(userId);
|
|
179
166
|
|
|
180
|
-
return toEndUserAccount(CdpOpenApiClient, { endUser
|
|
167
|
+
return toEndUserAccount(CdpOpenApiClient, { endUser });
|
|
181
168
|
}
|
|
182
169
|
|
|
183
170
|
/**
|
|
@@ -273,6 +260,34 @@ export class CDPEndUserClient {
|
|
|
273
260
|
return CdpOpenApiClient.addEndUserSolanaAccount(userId, {});
|
|
274
261
|
}
|
|
275
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Gets the active delegation for the specified end user, if one exists.
|
|
265
|
+
* This operation can be performed by the end user themselves or by a developer using their API key.
|
|
266
|
+
*
|
|
267
|
+
* @param options - The options for getting the delegation.
|
|
268
|
+
*
|
|
269
|
+
* @returns A promise that resolves to the delegation details including its expiry.
|
|
270
|
+
*
|
|
271
|
+
* @example **Get the active delegation for an end user**
|
|
272
|
+
* ```ts
|
|
273
|
+
* const delegation = await cdp.endUser.getDelegationForEndUser({
|
|
274
|
+
* userId: "user-123"
|
|
275
|
+
* });
|
|
276
|
+
* console.log(delegation.expiresAt);
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
async getDelegationForEndUser(
|
|
280
|
+
options: GetDelegationForEndUserOptions,
|
|
281
|
+
): Promise<GetDelegationForEndUserResult> {
|
|
282
|
+
Analytics.trackAction({
|
|
283
|
+
action: "get_delegation_for_end_user",
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const { userId } = options;
|
|
287
|
+
|
|
288
|
+
return CdpOpenApiClient.getDelegationForEndUser(userId);
|
|
289
|
+
}
|
|
290
|
+
|
|
276
291
|
/**
|
|
277
292
|
* Revokes all active delegations for the specified end user.
|
|
278
293
|
* This operation can be performed by the end user themselves or by a developer using their API key.
|
|
@@ -295,38 +310,11 @@ export class CDPEndUserClient {
|
|
|
295
310
|
|
|
296
311
|
const { userId } = options;
|
|
297
312
|
|
|
298
|
-
await CdpOpenApiClient.revokeDelegationForEndUser(
|
|
313
|
+
await CdpOpenApiClient.revokeDelegationForEndUser(userId, {});
|
|
299
314
|
}
|
|
300
315
|
|
|
301
316
|
// ─── Delegated EVM Sign Methods ───
|
|
302
317
|
|
|
303
|
-
/**
|
|
304
|
-
* Signs an EVM hash on behalf of an end user using a delegation.
|
|
305
|
-
* The end user must have previously created a delegation granting signing permissions.
|
|
306
|
-
*
|
|
307
|
-
* @param options - The options for signing an EVM hash.
|
|
308
|
-
*
|
|
309
|
-
* @returns A promise that resolves to the signature.
|
|
310
|
-
*
|
|
311
|
-
* @example
|
|
312
|
-
* ```ts
|
|
313
|
-
* const result = await cdp.endUser.signEvmHash({
|
|
314
|
-
* userId: "user-123",
|
|
315
|
-
* hash: "0xabcdef...",
|
|
316
|
-
* address: "0x1234..."
|
|
317
|
-
* });
|
|
318
|
-
* console.log(result.signature);
|
|
319
|
-
* ```
|
|
320
|
-
*/
|
|
321
|
-
async signEvmHash(options: SignEvmHashOptions): Promise<SignEvmHashResult> {
|
|
322
|
-
Analytics.trackAction({ action: "end_user_sign_evm_hash" });
|
|
323
|
-
|
|
324
|
-
return CdpOpenApiClient.signEvmHashWithEndUserAccount(this.requireProjectId(), options.userId, {
|
|
325
|
-
hash: options.hash,
|
|
326
|
-
address: options.address,
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
330
318
|
/**
|
|
331
319
|
* Signs an EVM transaction on behalf of an end user using a delegation.
|
|
332
320
|
*
|
|
@@ -347,14 +335,10 @@ export class CDPEndUserClient {
|
|
|
347
335
|
async signEvmTransaction(options: SignEvmTransactionOptions): Promise<SignEvmTransactionResult> {
|
|
348
336
|
Analytics.trackAction({ action: "end_user_sign_evm_transaction" });
|
|
349
337
|
|
|
350
|
-
return CdpOpenApiClient.signEvmTransactionWithEndUserAccount(
|
|
351
|
-
|
|
352
|
-
options.
|
|
353
|
-
|
|
354
|
-
address: options.address,
|
|
355
|
-
transaction: options.transaction,
|
|
356
|
-
},
|
|
357
|
-
);
|
|
338
|
+
return CdpOpenApiClient.signEvmTransactionWithEndUserAccount(options.userId, {
|
|
339
|
+
address: options.address,
|
|
340
|
+
transaction: options.transaction,
|
|
341
|
+
});
|
|
358
342
|
}
|
|
359
343
|
|
|
360
344
|
/**
|
|
@@ -377,14 +361,10 @@ export class CDPEndUserClient {
|
|
|
377
361
|
async signEvmMessage(options: SignEvmMessageOptions): Promise<SignEvmMessageResult> {
|
|
378
362
|
Analytics.trackAction({ action: "end_user_sign_evm_message" });
|
|
379
363
|
|
|
380
|
-
return CdpOpenApiClient.signEvmMessageWithEndUserAccount(
|
|
381
|
-
|
|
382
|
-
options.
|
|
383
|
-
|
|
384
|
-
address: options.address,
|
|
385
|
-
message: options.message,
|
|
386
|
-
},
|
|
387
|
-
);
|
|
364
|
+
return CdpOpenApiClient.signEvmMessageWithEndUserAccount(options.userId, {
|
|
365
|
+
address: options.address,
|
|
366
|
+
message: options.message,
|
|
367
|
+
});
|
|
388
368
|
}
|
|
389
369
|
|
|
390
370
|
/**
|
|
@@ -407,14 +387,10 @@ export class CDPEndUserClient {
|
|
|
407
387
|
async signEvmTypedData(options: SignEvmTypedDataOptions): Promise<SignEvmTypedDataResult> {
|
|
408
388
|
Analytics.trackAction({ action: "end_user_sign_evm_typed_data" });
|
|
409
389
|
|
|
410
|
-
return CdpOpenApiClient.signEvmTypedDataWithEndUserAccount(
|
|
411
|
-
|
|
412
|
-
options.
|
|
413
|
-
|
|
414
|
-
address: options.address,
|
|
415
|
-
typedData: options.typedData,
|
|
416
|
-
},
|
|
417
|
-
);
|
|
390
|
+
return CdpOpenApiClient.signEvmTypedDataWithEndUserAccount(options.userId, {
|
|
391
|
+
address: options.address,
|
|
392
|
+
typedData: options.typedData,
|
|
393
|
+
});
|
|
418
394
|
}
|
|
419
395
|
|
|
420
396
|
// ─── Delegated EVM Send Methods ───
|
|
@@ -440,15 +416,11 @@ export class CDPEndUserClient {
|
|
|
440
416
|
async sendEvmTransaction(options: SendEvmTransactionOptions): Promise<SendEvmTransactionResult> {
|
|
441
417
|
Analytics.trackAction({ action: "end_user_send_evm_transaction" });
|
|
442
418
|
|
|
443
|
-
return CdpOpenApiClient.sendEvmTransactionWithEndUserAccount(
|
|
444
|
-
|
|
445
|
-
options.
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
transaction: options.transaction,
|
|
449
|
-
network: options.network,
|
|
450
|
-
},
|
|
451
|
-
);
|
|
419
|
+
return CdpOpenApiClient.sendEvmTransactionWithEndUserAccount(options.userId, {
|
|
420
|
+
address: options.address,
|
|
421
|
+
transaction: options.transaction,
|
|
422
|
+
network: options.network,
|
|
423
|
+
});
|
|
452
424
|
}
|
|
453
425
|
|
|
454
426
|
/**
|
|
@@ -475,19 +447,13 @@ export class CDPEndUserClient {
|
|
|
475
447
|
|
|
476
448
|
const asset = options.asset ?? "usdc";
|
|
477
449
|
|
|
478
|
-
return CdpOpenApiClient.sendEvmAssetWithEndUserAccount(
|
|
479
|
-
|
|
480
|
-
options.
|
|
481
|
-
options.
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
amount: options.amount,
|
|
486
|
-
network: options.network,
|
|
487
|
-
useCdpPaymaster: options.useCdpPaymaster,
|
|
488
|
-
paymasterUrl: options.paymasterUrl,
|
|
489
|
-
},
|
|
490
|
-
);
|
|
450
|
+
return CdpOpenApiClient.sendEvmAssetWithEndUserAccount(options.userId, options.address, asset, {
|
|
451
|
+
to: options.to,
|
|
452
|
+
amount: options.amount,
|
|
453
|
+
network: options.network,
|
|
454
|
+
useCdpPaymaster: options.useCdpPaymaster,
|
|
455
|
+
paymasterUrl: options.paymasterUrl,
|
|
456
|
+
});
|
|
491
457
|
}
|
|
492
458
|
|
|
493
459
|
/**
|
|
@@ -511,18 +477,13 @@ export class CDPEndUserClient {
|
|
|
511
477
|
async sendUserOperation(options: SendUserOperationOptions): Promise<SendUserOperationResult> {
|
|
512
478
|
Analytics.trackAction({ action: "end_user_send_user_operation" });
|
|
513
479
|
|
|
514
|
-
return CdpOpenApiClient.sendUserOperationWithEndUserAccount(
|
|
515
|
-
|
|
516
|
-
options.
|
|
517
|
-
options.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
useCdpPaymaster: options.useCdpPaymaster,
|
|
522
|
-
paymasterUrl: options.paymasterUrl,
|
|
523
|
-
dataSuffix: options.dataSuffix,
|
|
524
|
-
},
|
|
525
|
-
);
|
|
480
|
+
return CdpOpenApiClient.sendUserOperationWithEndUserAccount(options.userId, options.address, {
|
|
481
|
+
network: options.network,
|
|
482
|
+
calls: options.calls,
|
|
483
|
+
useCdpPaymaster: options.useCdpPaymaster,
|
|
484
|
+
paymasterUrl: options.paymasterUrl,
|
|
485
|
+
dataSuffix: options.dataSuffix,
|
|
486
|
+
});
|
|
526
487
|
}
|
|
527
488
|
|
|
528
489
|
// ─── Delegated EVM EIP-7702 Delegation Method ───
|
|
@@ -549,49 +510,15 @@ export class CDPEndUserClient {
|
|
|
549
510
|
): Promise<CreateEvmEip7702DelegationForEndUserResult> {
|
|
550
511
|
Analytics.trackAction({ action: "end_user_create_evm_eip7702_delegation" });
|
|
551
512
|
|
|
552
|
-
return CdpOpenApiClient.createEvmEip7702DelegationWithEndUserAccount(
|
|
553
|
-
|
|
554
|
-
options.
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
network: options.network,
|
|
558
|
-
enableSpendPermissions: options.enableSpendPermissions,
|
|
559
|
-
},
|
|
560
|
-
);
|
|
513
|
+
return CdpOpenApiClient.createEvmEip7702DelegationWithEndUserAccount(options.userId, {
|
|
514
|
+
address: options.address,
|
|
515
|
+
network: options.network,
|
|
516
|
+
enableSpendPermissions: options.enableSpendPermissions,
|
|
517
|
+
});
|
|
561
518
|
}
|
|
562
519
|
|
|
563
520
|
// ─── Delegated Solana Sign Methods ───
|
|
564
521
|
|
|
565
|
-
/**
|
|
566
|
-
* Signs a Solana hash on behalf of an end user using a delegation.
|
|
567
|
-
*
|
|
568
|
-
* @param options - The options for signing a Solana hash.
|
|
569
|
-
*
|
|
570
|
-
* @returns A promise that resolves to the signature.
|
|
571
|
-
*
|
|
572
|
-
* @example
|
|
573
|
-
* ```ts
|
|
574
|
-
* const result = await cdp.endUser.signSolanaHash({
|
|
575
|
-
* userId: "user-123",
|
|
576
|
-
* hash: "base64hash...",
|
|
577
|
-
* address: "So1ana..."
|
|
578
|
-
* });
|
|
579
|
-
* console.log(result.signature);
|
|
580
|
-
* ```
|
|
581
|
-
*/
|
|
582
|
-
async signSolanaHash(options: SignSolanaHashOptions): Promise<SignSolanaHashResult> {
|
|
583
|
-
Analytics.trackAction({ action: "end_user_sign_solana_hash" });
|
|
584
|
-
|
|
585
|
-
return CdpOpenApiClient.signSolanaHashWithEndUserAccount(
|
|
586
|
-
this.requireProjectId(),
|
|
587
|
-
options.userId,
|
|
588
|
-
{
|
|
589
|
-
hash: options.hash,
|
|
590
|
-
address: options.address,
|
|
591
|
-
},
|
|
592
|
-
);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
522
|
/**
|
|
596
523
|
* Signs a Solana message on behalf of an end user using a delegation.
|
|
597
524
|
*
|
|
@@ -612,14 +539,10 @@ export class CDPEndUserClient {
|
|
|
612
539
|
async signSolanaMessage(options: SignSolanaMessageOptions): Promise<SignSolanaMessageResult> {
|
|
613
540
|
Analytics.trackAction({ action: "end_user_sign_solana_message" });
|
|
614
541
|
|
|
615
|
-
return CdpOpenApiClient.signSolanaMessageWithEndUserAccount(
|
|
616
|
-
|
|
617
|
-
options.
|
|
618
|
-
|
|
619
|
-
address: options.address,
|
|
620
|
-
message: options.message,
|
|
621
|
-
},
|
|
622
|
-
);
|
|
542
|
+
return CdpOpenApiClient.signSolanaMessageWithEndUserAccount(options.userId, {
|
|
543
|
+
address: options.address,
|
|
544
|
+
message: options.message,
|
|
545
|
+
});
|
|
623
546
|
}
|
|
624
547
|
|
|
625
548
|
/**
|
|
@@ -644,14 +567,10 @@ export class CDPEndUserClient {
|
|
|
644
567
|
): Promise<SignSolanaTransactionResult> {
|
|
645
568
|
Analytics.trackAction({ action: "end_user_sign_solana_transaction" });
|
|
646
569
|
|
|
647
|
-
return CdpOpenApiClient.signSolanaTransactionWithEndUserAccount(
|
|
648
|
-
|
|
649
|
-
options.
|
|
650
|
-
|
|
651
|
-
address: options.address,
|
|
652
|
-
transaction: options.transaction,
|
|
653
|
-
},
|
|
654
|
-
);
|
|
570
|
+
return CdpOpenApiClient.signSolanaTransactionWithEndUserAccount(options.userId, {
|
|
571
|
+
address: options.address,
|
|
572
|
+
transaction: options.transaction,
|
|
573
|
+
});
|
|
655
574
|
}
|
|
656
575
|
|
|
657
576
|
// ─── Delegated Solana Send Methods ───
|
|
@@ -679,15 +598,11 @@ export class CDPEndUserClient {
|
|
|
679
598
|
): Promise<SendSolanaTransactionResult> {
|
|
680
599
|
Analytics.trackAction({ action: "end_user_send_solana_transaction" });
|
|
681
600
|
|
|
682
|
-
return CdpOpenApiClient.sendSolanaTransactionWithEndUserAccount(
|
|
683
|
-
|
|
684
|
-
options.
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
transaction: options.transaction,
|
|
688
|
-
network: options.network,
|
|
689
|
-
},
|
|
690
|
-
);
|
|
601
|
+
return CdpOpenApiClient.sendSolanaTransactionWithEndUserAccount(options.userId, {
|
|
602
|
+
address: options.address,
|
|
603
|
+
transaction: options.transaction,
|
|
604
|
+
network: options.network,
|
|
605
|
+
});
|
|
691
606
|
}
|
|
692
607
|
|
|
693
608
|
/**
|
|
@@ -715,7 +630,6 @@ export class CDPEndUserClient {
|
|
|
715
630
|
const asset = options.asset ?? "usdc";
|
|
716
631
|
|
|
717
632
|
return CdpOpenApiClient.sendSolanaAssetWithEndUserAccount(
|
|
718
|
-
this.requireProjectId(),
|
|
719
633
|
options.userId,
|
|
720
634
|
options.address,
|
|
721
635
|
asset,
|
|
@@ -746,7 +660,7 @@ export class CDPEndUserClient {
|
|
|
746
660
|
accessToken,
|
|
747
661
|
});
|
|
748
662
|
|
|
749
|
-
return toEndUserAccount(CdpOpenApiClient, { endUser
|
|
663
|
+
return toEndUserAccount(CdpOpenApiClient, { endUser });
|
|
750
664
|
}
|
|
751
665
|
|
|
752
666
|
/**
|
|
@@ -835,22 +749,6 @@ export class CDPEndUserClient {
|
|
|
835
749
|
keyType: options.keyType,
|
|
836
750
|
});
|
|
837
751
|
|
|
838
|
-
return toEndUserAccount(CdpOpenApiClient, { endUser
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
/**
|
|
842
|
-
* Returns the configured project ID or throws if not configured.
|
|
843
|
-
*
|
|
844
|
-
* @returns The project ID.
|
|
845
|
-
*/
|
|
846
|
-
private requireProjectId(): string {
|
|
847
|
-
if (!this.projectId) {
|
|
848
|
-
throw new UserInputValidationError(
|
|
849
|
-
"Missing required project ID for delegation operation. " +
|
|
850
|
-
"Set the CDP_PROJECT_ID environment variable or pass projectId to the CdpClient constructor.",
|
|
851
|
-
);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
return this.projectId;
|
|
752
|
+
return toEndUserAccount(CdpOpenApiClient, { endUser });
|
|
855
753
|
}
|
|
856
754
|
}
|