@coinbase/cdp-sdk 1.44.1 → 1.46.0
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 +28 -2
- package/README.md +164 -43
- package/_cjs/accounts/evm/eip6492.js +49 -0
- package/_cjs/accounts/evm/eip6492.js.map +1 -0
- package/_cjs/accounts/evm/toEvmDelegatedAccount.js +27 -0
- package/_cjs/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +127 -55
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +115 -45
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +31 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +49 -19
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js +37 -0
- package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
- package/_cjs/actions/solana/transfer.js.map +1 -1
- package/_cjs/actions/solana/utils.js +9 -9
- package/_cjs/actions/solana/utils.js.map +1 -1
- package/_cjs/analytics.js +10 -228
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/auth/utils/http.js +1 -0
- package/_cjs/auth/utils/http.js.map +1 -1
- package/_cjs/client/cdp.js +4 -7
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/end-user/endUser.js +385 -4
- package/_cjs/client/end-user/endUser.js.map +1 -1
- package/_cjs/client/end-user/toEndUserAccount.js +201 -23
- package/_cjs/client/end-user/toEndUserAccount.js.map +1 -1
- package/_cjs/client/evm/evm.js +482 -227
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/policies/policies.js +41 -11
- package/_cjs/client/policies/policies.js.map +1 -1
- package/_cjs/client/solana/solana.js +215 -118
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/index.js +3 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/cdpApiClient.js +32 -0
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +178 -9
- 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 +261 -0
- package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +1 -0
- package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +30 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +2 -2
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
- package/_cjs/openapi-client/generated/faucets/faucets.js +6 -5
- package/_cjs/openapi-client/generated/faucets/faucets.js.map +1 -1
- package/_cjs/openapi-client/generated/onchain-data/onchain-data.js.map +1 -1
- package/_cjs/openapi-client/generated/onramp/onramp.js +15 -1
- package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -1
- package/_cjs/openapi-client/generated/sql-api/sql-api.js +75 -0
- package/_cjs/openapi-client/generated/sql-api/sql-api.js.map +1 -0
- package/_cjs/openapi-client/generated/webhooks/webhooks.js.map +1 -1
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -1
- package/_cjs/openapi-client/index.js +4 -1
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/policies/evmSchema.js +127 -1
- package/_cjs/policies/evmSchema.js.map +1 -1
- package/_cjs/policies/solanaSchema.js +102 -1
- package/_cjs/policies/solanaSchema.js.map +1 -1
- package/_cjs/policies/types.js +7 -0
- package/_cjs/policies/types.js.map +1 -1
- package/_cjs/utils/export.js +6 -5
- package/_cjs/utils/export.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/eip6492.js +46 -0
- package/_esm/accounts/evm/eip6492.js.map +1 -0
- package/_esm/accounts/evm/toEvmDelegatedAccount.js +24 -0
- package/_esm/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
- package/_esm/accounts/evm/toEvmServerAccount.js +127 -55
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +115 -45
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +31 -0
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +49 -19
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js +34 -0
- package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
- package/_esm/actions/solana/transfer.js.map +1 -1
- package/_esm/actions/solana/utils.js +9 -9
- package/_esm/actions/solana/utils.js.map +1 -1
- package/_esm/analytics.js +9 -227
- package/_esm/analytics.js.map +1 -1
- package/_esm/auth/utils/http.js +1 -0
- package/_esm/auth/utils/http.js.map +1 -1
- package/_esm/client/cdp.js +4 -7
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/end-user/endUser.js +385 -4
- package/_esm/client/end-user/endUser.js.map +1 -1
- package/_esm/client/end-user/toEndUserAccount.js +201 -23
- package/_esm/client/end-user/toEndUserAccount.js.map +1 -1
- package/_esm/client/evm/evm.js +482 -227
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/policies/policies.js +41 -11
- package/_esm/client/policies/policies.js.map +1 -1
- package/_esm/client/solana/solana.js +215 -118
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/cdpApiClient.js +32 -0
- package/_esm/openapi-client/cdpApiClient.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +175 -7
- 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 +243 -0
- package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +1 -0
- package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +27 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +2 -2
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -1
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
- package/_esm/openapi-client/generated/faucets/faucets.js +6 -5
- package/_esm/openapi-client/generated/faucets/faucets.js.map +1 -1
- package/_esm/openapi-client/generated/onchain-data/onchain-data.js.map +1 -1
- package/_esm/openapi-client/generated/onramp/onramp.js +13 -0
- package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -1
- package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -1
- package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -1
- package/_esm/openapi-client/generated/sql-api/sql-api.js +70 -0
- package/_esm/openapi-client/generated/sql-api/sql-api.js.map +1 -0
- package/_esm/openapi-client/generated/webhooks/webhooks.js.map +1 -1
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -1
- package/_esm/openapi-client/index.js +4 -1
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/policies/evmSchema.js +126 -0
- package/_esm/policies/evmSchema.js.map +1 -1
- package/_esm/policies/solanaSchema.js +101 -0
- package/_esm/policies/solanaSchema.js.map +1 -1
- package/_esm/policies/types.js +9 -2
- package/_esm/policies/types.js.map +1 -1
- package/_esm/utils/export.js +6 -5
- package/_esm/utils/export.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/eip6492.d.ts +17 -0
- package/_types/accounts/evm/eip6492.d.ts.map +1 -0
- package/_types/accounts/evm/toEvmDelegatedAccount.d.ts +13 -0
- package/_types/accounts/evm/toEvmDelegatedAccount.d.ts.map +1 -0
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts +4 -4
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +3 -2
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts +32 -0
- package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts.map +1 -0
- package/_types/actions/solana/transfer.d.ts +3 -4
- package/_types/actions/solana/transfer.d.ts.map +1 -1
- package/_types/actions/solana/types.d.ts +79 -29
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/actions/solana/utils.d.ts +10 -9
- package/_types/actions/solana/utils.d.ts.map +1 -1
- package/_types/analytics.d.ts +5 -38
- package/_types/analytics.d.ts.map +1 -1
- package/_types/auth/utils/http.d.ts.map +1 -1
- package/_types/client/cdp.d.ts +4 -0
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/end-user/endUser.d.ts +272 -1
- package/_types/client/end-user/endUser.d.ts.map +1 -1
- package/_types/client/end-user/endUser.types.d.ts +491 -1
- package/_types/client/end-user/endUser.types.d.ts.map +1 -1
- package/_types/client/end-user/toEndUserAccount.d.ts +4 -1
- package/_types/client/end-user/toEndUserAccount.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +54 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +29 -2
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/policies/policies.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +38 -12
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/index.d.ts +3 -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 +884 -90
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts +163 -0
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts.map +1 -0
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts +9 -9
- package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +35 -15
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +14 -14
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts +3 -3
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts +2 -2
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts.map +1 -1
- package/_types/openapi-client/generated/faucets/faucets.d.ts +9 -8
- package/_types/openapi-client/generated/faucets/faucets.d.ts.map +1 -1
- package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts +3 -3
- package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts.map +1 -1
- package/_types/openapi-client/generated/onramp/onramp.d.ts +12 -5
- package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +6 -6
- package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +12 -12
- package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts +2 -2
- package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts.map +1 -1
- package/_types/openapi-client/generated/sql-api/sql-api.d.ts +73 -0
- package/_types/openapi-client/generated/sql-api/sql-api.d.ts.map +1 -0
- package/_types/openapi-client/generated/webhooks/webhooks.d.ts +6 -6
- package/_types/openapi-client/generated/webhooks/webhooks.d.ts.map +1 -1
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts +4 -4
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +23 -3
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/policies/evmSchema.d.ts +3128 -1064
- package/_types/policies/evmSchema.d.ts.map +1 -1
- package/_types/policies/solanaSchema.d.ts +1411 -47
- package/_types/policies/solanaSchema.d.ts.map +1 -1
- package/_types/policies/types.d.ts +8427 -2942
- package/_types/policies/types.d.ts.map +1 -1
- package/_types/types/contract.d.ts.map +1 -1
- package/_types/utils/export.d.ts +1 -1
- package/_types/utils/export.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/eip6492.ts +60 -0
- package/accounts/evm/toEvmDelegatedAccount.ts +26 -0
- package/accounts/evm/toEvmServerAccount.ts +115 -67
- package/accounts/evm/toEvmSmartAccount.ts +114 -57
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +44 -5
- package/accounts/evm/types.ts +8 -3
- package/accounts/solana/toSolanaAccount.ts +44 -24
- package/actions/evm/waitForEvmEip7702DelegationStatus.ts +57 -0
- package/actions/solana/transfer.ts +3 -3
- package/actions/solana/types.ts +79 -29
- package/actions/solana/utils.ts +13 -11
- package/analytics.ts +8 -294
- package/auth/utils/http.ts +1 -0
- package/client/cdp.ts +6 -8
- package/client/end-user/endUser.ts +513 -4
- package/client/end-user/endUser.types.ts +598 -0
- package/client/end-user/toEndUserAccount.ts +330 -26
- package/client/evm/evm.ts +517 -282
- package/client/evm/evm.types.ts +45 -2
- package/client/policies/policies.ts +41 -16
- package/client/solana/solana.ts +233 -153
- package/index.ts +36 -1
- package/openapi-client/cdpApiClient.ts +34 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +1155 -172
- package/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.ts +455 -0
- package/openapi-client/generated/end-user-accounts/end-user-accounts.ts +12 -9
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +66 -14
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +16 -16
- package/openapi-client/generated/evm-swaps/evm-swaps.ts +3 -3
- package/openapi-client/generated/evm-token-balances/evm-token-balances.ts +2 -2
- package/openapi-client/generated/faucets/faucets.ts +9 -8
- package/openapi-client/generated/onchain-data/onchain-data.ts +3 -3
- package/openapi-client/generated/onramp/onramp.ts +28 -4
- package/openapi-client/generated/policy-engine/policy-engine.ts +12 -6
- package/openapi-client/generated/solana-accounts/solana-accounts.ts +12 -12
- package/openapi-client/generated/solana-token-balances/solana-token-balances.ts +2 -2
- package/openapi-client/generated/sql-api/sql-api.ts +92 -0
- package/openapi-client/generated/webhooks/webhooks.ts +6 -6
- package/openapi-client/generated/x402-facilitator/x402-facilitator.ts +6 -4
- package/openapi-client/index.ts +4 -1
- package/package.json +7 -8
- package/policies/evmSchema.ts +164 -0
- package/policies/solanaSchema.ts +130 -0
- package/policies/types.ts +14 -0
- package/types/contract.ts +2 -4
- package/utils/export.ts +6 -5
- package/version.ts +1 -1
- package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +0 -55
- package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +0 -1
- package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +0 -50
- package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +0 -1
- package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts +0 -53
- package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts.map +0 -1
- package/openapi-client/generated/sql-api-alpha/sql-api-alpha.ts +0 -72
|
@@ -6,6 +6,32 @@ import type {
|
|
|
6
6
|
AddEndUserEvmSmartAccountResult,
|
|
7
7
|
AddEndUserSolanaAccountResult,
|
|
8
8
|
AddEvmSmartAccountOptions,
|
|
9
|
+
SignEvmHashResult,
|
|
10
|
+
SignEvmTransactionResult,
|
|
11
|
+
SignEvmMessageResult,
|
|
12
|
+
SignEvmTypedDataResult,
|
|
13
|
+
SendEvmTransactionResult,
|
|
14
|
+
SendEvmAssetResult,
|
|
15
|
+
SendUserOperationResult,
|
|
16
|
+
CreateEvmEip7702DelegationForEndUserResult,
|
|
17
|
+
SignSolanaHashResult,
|
|
18
|
+
SignSolanaMessageResult,
|
|
19
|
+
SignSolanaTransactionResult,
|
|
20
|
+
SendSolanaTransactionResult,
|
|
21
|
+
SendSolanaAssetResult,
|
|
22
|
+
AccountSignEvmHashOptions,
|
|
23
|
+
AccountSignEvmTransactionOptions,
|
|
24
|
+
AccountSignEvmMessageOptions,
|
|
25
|
+
AccountSignEvmTypedDataOptions,
|
|
26
|
+
AccountSendEvmTransactionOptions,
|
|
27
|
+
AccountSendEvmAssetOptions,
|
|
28
|
+
AccountSendUserOperationOptions,
|
|
29
|
+
AccountCreateEvmEip7702DelegationOptions,
|
|
30
|
+
AccountSignSolanaHashOptions,
|
|
31
|
+
AccountSignSolanaMessageOptions,
|
|
32
|
+
AccountSignSolanaTransactionOptions,
|
|
33
|
+
AccountSendSolanaTransactionOptions,
|
|
34
|
+
AccountSendSolanaAssetOptions,
|
|
9
35
|
} from "./endUser.types.js";
|
|
10
36
|
import type {
|
|
11
37
|
CdpOpenApiClientType,
|
|
@@ -18,11 +44,83 @@ import type {
|
|
|
18
44
|
export type ToEndUserAccountOptions = {
|
|
19
45
|
/** The end user from the API response. */
|
|
20
46
|
endUser: OpenAPIEndUser;
|
|
47
|
+
/** The CDP project ID. Required for delegation operations (signing, sending). */
|
|
48
|
+
projectId?: string;
|
|
21
49
|
};
|
|
22
50
|
|
|
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
|
+
/**
|
|
70
|
+
* Resolves the first EVM EOA address for this end user, or throws if none exist and no override was provided.
|
|
71
|
+
*
|
|
72
|
+
* @param endUser - The OpenAPI end user.
|
|
73
|
+
* @param override - An optional address override.
|
|
74
|
+
* @returns The resolved EVM address.
|
|
75
|
+
*/
|
|
76
|
+
function resolveEvmAddress(endUser: OpenAPIEndUser, override?: string): string {
|
|
77
|
+
const address = override ?? endUser.evmAccountObjects[0]?.address;
|
|
78
|
+
if (!address) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"No EVM account found on this end user. Provide an explicit address or add an EVM account first.",
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return address;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Resolves the first EVM smart account address for this end user, or throws if none exist and no override was provided.
|
|
88
|
+
*
|
|
89
|
+
* @param endUser - The OpenAPI end user.
|
|
90
|
+
* @param override - An optional address override.
|
|
91
|
+
* @returns The resolved EVM smart account address.
|
|
92
|
+
*/
|
|
93
|
+
function resolveEvmSmartAccountAddress(endUser: OpenAPIEndUser, override?: string): string {
|
|
94
|
+
const address = override ?? endUser.evmSmartAccountObjects[0]?.address;
|
|
95
|
+
if (!address) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
"No EVM smart account found on this end user. Provide an explicit address or add an EVM smart account first.",
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return address;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Resolves the first Solana address for this end user, or throws if none exist and no override was provided.
|
|
105
|
+
*
|
|
106
|
+
* @param endUser - The OpenAPI end user.
|
|
107
|
+
* @param override - An optional address override.
|
|
108
|
+
* @returns The resolved Solana address.
|
|
109
|
+
*/
|
|
110
|
+
function resolveSolanaAddress(endUser: OpenAPIEndUser, override?: string): string {
|
|
111
|
+
const address = override ?? endUser.solanaAccountObjects[0]?.address;
|
|
112
|
+
if (!address) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
"No Solana account found on this end user. Provide an explicit address or add a Solana account first.",
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
return address;
|
|
118
|
+
}
|
|
119
|
+
|
|
23
120
|
/**
|
|
24
121
|
* Creates an EndUserAccount instance with actions from an existing OpenAPI EndUser.
|
|
25
|
-
* This wraps the raw API response and adds convenience methods for adding accounts
|
|
122
|
+
* This wraps the raw API response and adds convenience methods for adding accounts
|
|
123
|
+
* and performing delegated signing/sending operations.
|
|
26
124
|
*
|
|
27
125
|
* @param apiClient - The API client.
|
|
28
126
|
* @param options - Configuration options.
|
|
@@ -33,46 +131,252 @@ export function toEndUserAccount(
|
|
|
33
131
|
apiClient: CdpOpenApiClientType,
|
|
34
132
|
options: ToEndUserAccountOptions,
|
|
35
133
|
): EndUserAccount {
|
|
134
|
+
const { endUser, projectId } = options;
|
|
135
|
+
|
|
36
136
|
const endUserAccount: EndUserAccount = {
|
|
37
137
|
// Pass through all properties from the OpenAPI EndUser
|
|
38
|
-
userId:
|
|
39
|
-
authenticationMethods:
|
|
40
|
-
mfaMethods:
|
|
41
|
-
evmAccounts:
|
|
42
|
-
evmAccountObjects:
|
|
43
|
-
evmSmartAccounts:
|
|
44
|
-
evmSmartAccountObjects:
|
|
45
|
-
solanaAccounts:
|
|
46
|
-
solanaAccountObjects:
|
|
47
|
-
createdAt:
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
async addEvmAccount(): Promise<AddEndUserEvmAccountResult> {
|
|
51
|
-
Analytics.trackAction({
|
|
52
|
-
action: "end_user_add_evm_account",
|
|
53
|
-
});
|
|
138
|
+
userId: endUser.userId,
|
|
139
|
+
authenticationMethods: endUser.authenticationMethods,
|
|
140
|
+
mfaMethods: endUser.mfaMethods,
|
|
141
|
+
evmAccounts: endUser.evmAccounts,
|
|
142
|
+
evmAccountObjects: endUser.evmAccountObjects,
|
|
143
|
+
evmSmartAccounts: endUser.evmSmartAccounts,
|
|
144
|
+
evmSmartAccountObjects: endUser.evmSmartAccountObjects,
|
|
145
|
+
solanaAccounts: endUser.solanaAccounts,
|
|
146
|
+
solanaAccountObjects: endUser.solanaAccountObjects,
|
|
147
|
+
createdAt: endUser.createdAt,
|
|
148
|
+
|
|
149
|
+
// ─── Account Management Methods ───
|
|
54
150
|
|
|
55
|
-
|
|
151
|
+
async addEvmAccount(): Promise<AddEndUserEvmAccountResult> {
|
|
152
|
+
Analytics.trackAction({ action: "end_user_add_evm_account" });
|
|
153
|
+
return apiClient.addEndUserEvmAccount(endUser.userId, {});
|
|
56
154
|
},
|
|
57
155
|
|
|
58
156
|
async addEvmSmartAccount(
|
|
59
157
|
smartAccountOptions: AddEvmSmartAccountOptions,
|
|
60
158
|
): Promise<AddEndUserEvmSmartAccountResult> {
|
|
61
|
-
Analytics.trackAction({
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
return apiClient.addEndUserEvmSmartAccount(options.endUser.userId, {
|
|
159
|
+
Analytics.trackAction({ action: "end_user_add_evm_smart_account" });
|
|
160
|
+
return apiClient.addEndUserEvmSmartAccount(endUser.userId, {
|
|
66
161
|
enableSpendPermissions: smartAccountOptions.enableSpendPermissions,
|
|
67
162
|
});
|
|
68
163
|
},
|
|
69
164
|
|
|
70
165
|
async addSolanaAccount(): Promise<AddEndUserSolanaAccountResult> {
|
|
71
|
-
Analytics.trackAction({
|
|
72
|
-
|
|
166
|
+
Analytics.trackAction({ action: "end_user_add_solana_account" });
|
|
167
|
+
return apiClient.addEndUserSolanaAccount(endUser.userId, {});
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
async revokeDelegation(): Promise<void> {
|
|
171
|
+
Analytics.trackAction({ action: "end_user_revoke_delegation" });
|
|
172
|
+
await apiClient.revokeDelegationForEndUser(requireProjectId(projectId), endUser.userId, {});
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
// ─── Delegated EVM Sign Methods ───
|
|
176
|
+
|
|
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,
|
|
73
183
|
});
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
async signEvmTransaction(
|
|
187
|
+
opts: AccountSignEvmTransactionOptions,
|
|
188
|
+
): Promise<SignEvmTransactionResult> {
|
|
189
|
+
Analytics.trackAction({ action: "end_user_sign_evm_transaction" });
|
|
190
|
+
const address = resolveEvmAddress(endUser, opts.address);
|
|
191
|
+
return apiClient.signEvmTransactionWithEndUserAccount(
|
|
192
|
+
requireProjectId(projectId),
|
|
193
|
+
endUser.userId,
|
|
194
|
+
{
|
|
195
|
+
address,
|
|
196
|
+
transaction: opts.transaction,
|
|
197
|
+
},
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
async signEvmMessage(opts: AccountSignEvmMessageOptions): Promise<SignEvmMessageResult> {
|
|
202
|
+
Analytics.trackAction({ action: "end_user_sign_evm_message" });
|
|
203
|
+
const address = resolveEvmAddress(endUser, opts.address);
|
|
204
|
+
return apiClient.signEvmMessageWithEndUserAccount(
|
|
205
|
+
requireProjectId(projectId),
|
|
206
|
+
endUser.userId,
|
|
207
|
+
{
|
|
208
|
+
address,
|
|
209
|
+
message: opts.message,
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
async signEvmTypedData(opts: AccountSignEvmTypedDataOptions): Promise<SignEvmTypedDataResult> {
|
|
215
|
+
Analytics.trackAction({ action: "end_user_sign_evm_typed_data" });
|
|
216
|
+
const address = resolveEvmAddress(endUser, opts.address);
|
|
217
|
+
return apiClient.signEvmTypedDataWithEndUserAccount(
|
|
218
|
+
requireProjectId(projectId),
|
|
219
|
+
endUser.userId,
|
|
220
|
+
{
|
|
221
|
+
address,
|
|
222
|
+
typedData: opts.typedData,
|
|
223
|
+
},
|
|
224
|
+
);
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
// ─── Delegated EVM Send Methods ───
|
|
228
|
+
|
|
229
|
+
async sendEvmTransaction(
|
|
230
|
+
opts: AccountSendEvmTransactionOptions,
|
|
231
|
+
): Promise<SendEvmTransactionResult> {
|
|
232
|
+
Analytics.trackAction({ action: "end_user_send_evm_transaction" });
|
|
233
|
+
const address = resolveEvmAddress(endUser, opts.address);
|
|
234
|
+
return apiClient.sendEvmTransactionWithEndUserAccount(
|
|
235
|
+
requireProjectId(projectId),
|
|
236
|
+
endUser.userId,
|
|
237
|
+
{
|
|
238
|
+
address,
|
|
239
|
+
transaction: opts.transaction,
|
|
240
|
+
network: opts.network,
|
|
241
|
+
},
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
async sendEvmAsset(opts: AccountSendEvmAssetOptions): Promise<SendEvmAssetResult> {
|
|
246
|
+
Analytics.trackAction({ action: "end_user_send_evm_asset" });
|
|
247
|
+
const address = resolveEvmAddress(endUser, opts.address);
|
|
248
|
+
const asset = opts.asset ?? "usdc";
|
|
249
|
+
return apiClient.sendEvmAssetWithEndUserAccount(
|
|
250
|
+
requireProjectId(projectId),
|
|
251
|
+
endUser.userId,
|
|
252
|
+
address,
|
|
253
|
+
asset,
|
|
254
|
+
{
|
|
255
|
+
to: opts.to,
|
|
256
|
+
amount: opts.amount,
|
|
257
|
+
network: opts.network,
|
|
258
|
+
useCdpPaymaster: opts.useCdpPaymaster,
|
|
259
|
+
paymasterUrl: opts.paymasterUrl,
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
async sendUserOperation(
|
|
265
|
+
opts: AccountSendUserOperationOptions,
|
|
266
|
+
): Promise<SendUserOperationResult> {
|
|
267
|
+
Analytics.trackAction({ action: "end_user_send_user_operation" });
|
|
268
|
+
const address = resolveEvmSmartAccountAddress(endUser, opts.address);
|
|
269
|
+
return apiClient.sendUserOperationWithEndUserAccount(
|
|
270
|
+
requireProjectId(projectId),
|
|
271
|
+
endUser.userId,
|
|
272
|
+
address,
|
|
273
|
+
{
|
|
274
|
+
network: opts.network,
|
|
275
|
+
calls: opts.calls,
|
|
276
|
+
useCdpPaymaster: opts.useCdpPaymaster,
|
|
277
|
+
paymasterUrl: opts.paymasterUrl,
|
|
278
|
+
dataSuffix: opts.dataSuffix,
|
|
279
|
+
},
|
|
280
|
+
);
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
// ─── Delegated EVM EIP-7702 Delegation Method ───
|
|
284
|
+
|
|
285
|
+
async createEvmEip7702Delegation(
|
|
286
|
+
opts: AccountCreateEvmEip7702DelegationOptions,
|
|
287
|
+
): Promise<CreateEvmEip7702DelegationForEndUserResult> {
|
|
288
|
+
Analytics.trackAction({ action: "end_user_create_evm_eip7702_delegation" });
|
|
289
|
+
const address = resolveEvmAddress(endUser, opts.address);
|
|
290
|
+
return apiClient.createEvmEip7702DelegationWithEndUserAccount(
|
|
291
|
+
requireProjectId(projectId),
|
|
292
|
+
endUser.userId,
|
|
293
|
+
{
|
|
294
|
+
address,
|
|
295
|
+
network: opts.network,
|
|
296
|
+
enableSpendPermissions: opts.enableSpendPermissions,
|
|
297
|
+
},
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
// ─── Delegated Solana Sign Methods ───
|
|
302
|
+
|
|
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
|
+
async signSolanaMessage(
|
|
317
|
+
opts: AccountSignSolanaMessageOptions,
|
|
318
|
+
): Promise<SignSolanaMessageResult> {
|
|
319
|
+
Analytics.trackAction({ action: "end_user_sign_solana_message" });
|
|
320
|
+
const address = resolveSolanaAddress(endUser, opts.address);
|
|
321
|
+
return apiClient.signSolanaMessageWithEndUserAccount(
|
|
322
|
+
requireProjectId(projectId),
|
|
323
|
+
endUser.userId,
|
|
324
|
+
{
|
|
325
|
+
address,
|
|
326
|
+
message: opts.message,
|
|
327
|
+
},
|
|
328
|
+
);
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
async signSolanaTransaction(
|
|
332
|
+
opts: AccountSignSolanaTransactionOptions,
|
|
333
|
+
): Promise<SignSolanaTransactionResult> {
|
|
334
|
+
Analytics.trackAction({ action: "end_user_sign_solana_transaction" });
|
|
335
|
+
const address = resolveSolanaAddress(endUser, opts.address);
|
|
336
|
+
return apiClient.signSolanaTransactionWithEndUserAccount(
|
|
337
|
+
requireProjectId(projectId),
|
|
338
|
+
endUser.userId,
|
|
339
|
+
{
|
|
340
|
+
address,
|
|
341
|
+
transaction: opts.transaction,
|
|
342
|
+
},
|
|
343
|
+
);
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
// ─── Delegated Solana Send Methods ───
|
|
347
|
+
|
|
348
|
+
async sendSolanaTransaction(
|
|
349
|
+
opts: AccountSendSolanaTransactionOptions,
|
|
350
|
+
): Promise<SendSolanaTransactionResult> {
|
|
351
|
+
Analytics.trackAction({ action: "end_user_send_solana_transaction" });
|
|
352
|
+
const address = resolveSolanaAddress(endUser, opts.address);
|
|
353
|
+
return apiClient.sendSolanaTransactionWithEndUserAccount(
|
|
354
|
+
requireProjectId(projectId),
|
|
355
|
+
endUser.userId,
|
|
356
|
+
{
|
|
357
|
+
address,
|
|
358
|
+
transaction: opts.transaction,
|
|
359
|
+
network: opts.network,
|
|
360
|
+
},
|
|
361
|
+
);
|
|
362
|
+
},
|
|
74
363
|
|
|
75
|
-
|
|
364
|
+
async sendSolanaAsset(opts: AccountSendSolanaAssetOptions): Promise<SendSolanaAssetResult> {
|
|
365
|
+
Analytics.trackAction({ action: "end_user_send_solana_asset" });
|
|
366
|
+
const address = resolveSolanaAddress(endUser, opts.address);
|
|
367
|
+
const asset = opts.asset ?? "usdc";
|
|
368
|
+
return apiClient.sendSolanaAssetWithEndUserAccount(
|
|
369
|
+
requireProjectId(projectId),
|
|
370
|
+
endUser.userId,
|
|
371
|
+
address,
|
|
372
|
+
asset,
|
|
373
|
+
{
|
|
374
|
+
to: opts.to,
|
|
375
|
+
amount: opts.amount,
|
|
376
|
+
network: opts.network,
|
|
377
|
+
createRecipientAta: opts.createRecipientAta,
|
|
378
|
+
},
|
|
379
|
+
);
|
|
76
380
|
},
|
|
77
381
|
};
|
|
78
382
|
|