@coinbase/cdp-sdk 1.4.0 → 1.5.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +87 -2
  3. package/_cjs/accounts/evm/toEvmServerAccount.js +5 -0
  4. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  5. package/_cjs/accounts/evm/toEvmSmartAccount.js +7 -2
  6. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  7. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +72 -0
  8. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -0
  9. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +65 -0
  10. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -0
  11. package/_cjs/actions/evm/transfer/transfer.js +59 -0
  12. package/_cjs/actions/evm/transfer/transfer.js.map +1 -0
  13. package/_cjs/actions/evm/transfer/types.js +3 -0
  14. package/_cjs/actions/evm/transfer/types.js.map +1 -0
  15. package/_cjs/actions/evm/transfer/utils.js +39 -0
  16. package/_cjs/actions/evm/transfer/utils.js.map +1 -0
  17. package/_cjs/actions/evm/types.js +3 -0
  18. package/_cjs/actions/evm/types.js.map +1 -0
  19. package/_cjs/client/evm/evm.js +44 -2
  20. package/_cjs/client/evm/evm.js.map +1 -1
  21. package/_cjs/client/solana/solana.js +42 -0
  22. package/_cjs/client/solana/solana.js.map +1 -1
  23. package/_cjs/utils/serializeTransaction.js +18 -0
  24. package/_cjs/utils/serializeTransaction.js.map +1 -0
  25. package/_cjs/version.js +1 -1
  26. package/_esm/accounts/evm/toEvmServerAccount.js +5 -0
  27. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  28. package/_esm/accounts/evm/toEvmSmartAccount.js +7 -2
  29. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  30. package/_esm/actions/evm/transfer/accountTransferStrategy.js +69 -0
  31. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -0
  32. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +62 -0
  33. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -0
  34. package/_esm/actions/evm/transfer/transfer.js +56 -0
  35. package/_esm/actions/evm/transfer/transfer.js.map +1 -0
  36. package/_esm/actions/evm/transfer/types.js +2 -0
  37. package/_esm/actions/evm/transfer/types.js.map +1 -0
  38. package/_esm/actions/evm/transfer/utils.js +35 -0
  39. package/_esm/actions/evm/transfer/utils.js.map +1 -0
  40. package/_esm/actions/evm/types.js +2 -0
  41. package/_esm/actions/evm/types.js.map +1 -0
  42. package/_esm/client/evm/evm.js +44 -2
  43. package/_esm/client/evm/evm.js.map +1 -1
  44. package/_esm/client/solana/solana.js +42 -0
  45. package/_esm/client/solana/solana.js.map +1 -1
  46. package/_esm/utils/serializeTransaction.js +15 -0
  47. package/_esm/utils/serializeTransaction.js.map +1 -0
  48. package/_esm/version.js +1 -1
  49. package/_types/accounts/evm/toEvmServerAccount.d.ts +2 -2
  50. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  51. package/_types/accounts/evm/toEvmSmartAccount.d.ts +4 -4
  52. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  53. package/_types/accounts/types.d.ts +4 -3
  54. package/_types/accounts/types.d.ts.map +1 -1
  55. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +4 -0
  56. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -0
  57. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +4 -0
  58. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -0
  59. package/_types/actions/evm/transfer/transfer.d.ts +14 -0
  60. package/_types/actions/evm/transfer/transfer.d.ts.map +1 -0
  61. package/_types/actions/evm/transfer/types.d.ts +71 -0
  62. package/_types/actions/evm/transfer/types.d.ts.map +1 -0
  63. package/_types/actions/evm/transfer/utils.d.ts +631 -0
  64. package/_types/actions/evm/transfer/utils.d.ts.map +1 -0
  65. package/_types/actions/evm/types.d.ts +88 -0
  66. package/_types/actions/evm/types.d.ts.map +1 -0
  67. package/_types/client/evm/evm.d.ts +17 -1
  68. package/_types/client/evm/evm.d.ts.map +1 -1
  69. package/_types/client/evm/evm.types.d.ts +10 -1
  70. package/_types/client/evm/evm.types.d.ts.map +1 -1
  71. package/_types/client/solana/solana.d.ts +17 -1
  72. package/_types/client/solana/solana.d.ts.map +1 -1
  73. package/_types/client/solana/solana.types.d.ts +8 -0
  74. package/_types/client/solana/solana.types.d.ts.map +1 -1
  75. package/_types/utils/serializeTransaction.d.ts +9 -0
  76. package/_types/utils/serializeTransaction.d.ts.map +1 -0
  77. package/_types/version.d.ts +1 -1
  78. package/accounts/evm/toEvmServerAccount.ts +12 -6
  79. package/accounts/evm/toEvmSmartAccount.ts +16 -4
  80. package/accounts/types.ts +20 -16
  81. package/actions/evm/transfer/accountTransferStrategy.ts +84 -0
  82. package/actions/evm/transfer/smartAccountTransferStrategy.ts +70 -0
  83. package/actions/evm/transfer/transfer.ts +71 -0
  84. package/actions/evm/transfer/types.ts +81 -0
  85. package/actions/evm/transfer/utils.ts +39 -0
  86. package/actions/evm/types.ts +88 -0
  87. package/client/evm/evm.ts +45 -2
  88. package/client/evm/evm.types.ts +11 -1
  89. package/client/solana/solana.ts +43 -0
  90. package/client/solana/solana.types.ts +9 -0
  91. package/package.json +1 -1
  92. package/utils/serializeTransaction.ts +17 -0
  93. package/version.ts +1 -1
@@ -0,0 +1,88 @@
1
+ import { TransferOptions, TransferResult } from "./transfer/types.js";
2
+ export type Actions = {
3
+ /**
4
+ * Transfer an amount of a token from an account to another account.
5
+ *
6
+ * @param options - The options for the transfer.
7
+ * @param options.to - The account or 0x-prefixed address to transfer the token to.
8
+ * @param options.amount - The amount of the token to transfer.
9
+ * @param options.token - The token to transfer.
10
+ * @param options.network - The network to transfer the token on.
11
+ *
12
+ * @returns The result of the transfer.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const { status } = await sender.transfer({
17
+ * to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
18
+ * amount: "0.01",
19
+ * token: "usdc",
20
+ * network: "base-sepolia",
21
+ * });
22
+ * ```
23
+ *
24
+ * @example
25
+ * **Pass a bigint value**
26
+ * ```typescript
27
+ * const { status } = await sender.transfer({
28
+ * to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
29
+ * amount: 10000n, // equivalent to 0.01 usdc
30
+ * token: "usdc",
31
+ * network: "base-sepolia",
32
+ * });
33
+ * ```
34
+ *
35
+ * @example
36
+ * **Transfer from a smart account**
37
+ * ```typescript
38
+ * const sender = await cdp.evm.createSmartAccount({
39
+ * owner: await cdp.evm.createAccount({ name: "Owner" }),
40
+ * });
41
+ *
42
+ * const { status } = await sender.transfer({
43
+ * to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
44
+ * amount: "0.01",
45
+ * token: "usdc",
46
+ * network: "base-sepolia",
47
+ * });
48
+ * ```
49
+ *
50
+ * @example
51
+ * **Transfer ETH**
52
+ * ```typescript
53
+ * const { status } = await sender.transfer({
54
+ * to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
55
+ * amount: "0.000001",
56
+ * token: "eth",
57
+ * network: "base-sepolia",
58
+ * });
59
+ * ```
60
+ *
61
+ * @example
62
+ * **Using a contract address**
63
+ * ```typescript
64
+ * const { status } = await sender.transfer({
65
+ * to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
66
+ * amount: "0.000001",
67
+ * token: "0x4200000000000000000000000000000000000006", // WETH on Base Sepolia
68
+ * network: "base-sepolia",
69
+ * });
70
+ * ```
71
+ *
72
+ * @example
73
+ * **Transfer to another account**
74
+ * ```typescript
75
+ * const sender = await cdp.evm.createAccount({ name: "Sender" });
76
+ * const receiver = await cdp.evm.createAccount({ name: "Receiver" });
77
+ *
78
+ * const { status } = await sender.transfer({
79
+ * to: receiver,
80
+ * amount: "0.01",
81
+ * token: "usdc",
82
+ * network: "base-sepolia",
83
+ * });
84
+ * ```
85
+ */
86
+ transfer: (options: TransferOptions) => Promise<TransferResult>;
87
+ };
88
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../actions/evm/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEtE,MAAM,MAAM,OAAO,GAAG;IACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkFG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACjE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { CreateServerAccountOptions, GetServerAccountOptions, ListServerAccountsOptions, CreateSmartAccountOptions, RequestFaucetOptions, SendUserOperationOptions, WaitForUserOperationOptions, RequestFaucetResult, SignHashOptions, SignatureResult, SignMessageOptions, SignTransactionOptions, GetSmartAccountOptions, SmartAccount, ServerAccount, EvmClientInterface, ListServerAccountResult, PrepareUserOperationOptions, UserOperation, GetUserOperationOptions, ListSmartAccountResult, ListSmartAccountsOptions, ListTokenBalancesOptions, ListTokenBalancesResult, SendTransactionOptions, TransactionResult } from "./evm.types.js";
1
+ import { CreateServerAccountOptions, GetServerAccountOptions, ListServerAccountsOptions, CreateSmartAccountOptions, RequestFaucetOptions, SendUserOperationOptions, WaitForUserOperationOptions, RequestFaucetResult, SignHashOptions, SignatureResult, SignMessageOptions, SignTransactionOptions, GetSmartAccountOptions, SmartAccount, ServerAccount, EvmClientInterface, ListServerAccountResult, PrepareUserOperationOptions, UserOperation, GetUserOperationOptions, ListSmartAccountResult, ListSmartAccountsOptions, ListTokenBalancesOptions, ListTokenBalancesResult, SendTransactionOptions, TransactionResult, GetOrCreateServerAccountOptions } from "./evm.types.js";
2
2
  import { SendUserOperationReturnType } from "../../actions/evm/sendUserOperation.js";
3
3
  import { WaitForUserOperationReturnType } from "../../actions/evm/waitForUserOperation.js";
4
4
  /**
@@ -132,6 +132,22 @@ export declare class EvmClient implements EvmClientInterface {
132
132
  * ```
133
133
  */
134
134
  getSmartAccount(options: GetSmartAccountOptions): Promise<SmartAccount>;
135
+ /**
136
+ * Gets a CDP EVM account, or creates one if it doesn't exist.
137
+ *
138
+ * @param {GetOrCreateServerAccountOptions} options - Parameters for getting or creating the account.
139
+ * @param {string} [options.name] - The name of the account to get or create.
140
+ *
141
+ * @returns A promise that resolves to the account.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * const account = await cdp.evm.getOrCreateAccount({
146
+ * name: "MyAccount",
147
+ * });
148
+ * ```
149
+ */
150
+ getOrCreateAccount(options: GetOrCreateServerAccountOptions): Promise<ServerAccount>;
135
151
  /**
136
152
  * Gets a user operation for a smart account by user operation hash.
137
153
  *
@@ -1 +1 @@
1
- {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../client/evm/evm.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAEL,8BAA8B,EAC/B,MAAM,2CAA2C,CAAC;AAInD;;GAEG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BG;IACG,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAWhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAwBlF;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAShG;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAclE;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAcxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC;IAchF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,oBAAoB,CACxB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,8BAA8B,CAAC;CAK3C"}
@@ -1,5 +1,6 @@
1
1
  import { EvmAccount as Account, EvmServerAccount as ServerAccount, EvmSmartAccount as SmartAccount } from "../../accounts/types.js";
2
2
  import { SendUserOperationReturnType } from "../../actions/evm/sendUserOperation.js";
3
+ import { Actions } from "../../actions/evm/types.js";
3
4
  import { EvmUserOperationNetwork, EvmUserOperationStatus, OpenApiEvmMethods, ListEvmTokenBalancesNetwork, SendEvmTransactionBodyNetwork } from "../../openapi-client/index.js";
4
5
  import { Call, Calls } from "../../types/calls.js";
5
6
  import { Address, Hex, TransactionRequestEIP1559 } from "../../types/misc.js";
@@ -12,6 +13,7 @@ export type EvmClientInterface = Omit<typeof OpenApiEvmMethods, "createEvmAccoun
12
13
  createSmartAccount: (options: CreateSmartAccountOptions) => Promise<SmartAccount>;
13
14
  getAccount: (options: GetServerAccountOptions) => Promise<ServerAccount>;
14
15
  getSmartAccount: (options: GetSmartAccountOptions) => Promise<SmartAccount>;
16
+ getOrCreateAccount: (options: GetOrCreateServerAccountOptions) => Promise<ServerAccount>;
15
17
  getUserOperation: (options: GetUserOperationOptions) => Promise<UserOperation>;
16
18
  listAccounts: (options: ListServerAccountsOptions) => Promise<ListServerAccountResult>;
17
19
  listSmartAccounts: (options: ListSmartAccountsOptions) => Promise<ListSmartAccountResult>;
@@ -108,6 +110,13 @@ export interface GetSmartAccountOptions {
108
110
  /** The owner of the account. */
109
111
  owner: Account;
110
112
  }
113
+ /**
114
+ * Options for getting an EVM account, or creating one if it doesn't exist.
115
+ */
116
+ export interface GetOrCreateServerAccountOptions {
117
+ /** The name of the account. */
118
+ name: string;
119
+ }
111
120
  /**
112
121
  * Options for listing EVM accounts.
113
122
  */
@@ -120,7 +129,7 @@ export interface ListServerAccountsOptions {
120
129
  /**
121
130
  * A smart account that only contains the owner address.
122
131
  */
123
- export interface ReadonlySmartAccount extends Omit<SmartAccount, "owners"> {
132
+ export interface ReadonlySmartAccount extends Omit<SmartAccount, "owners" | keyof Actions> {
124
133
  /** The owners of the smart account. */
125
134
  owners: Address[];
126
135
  }
@@ -1 +1 @@
1
- {"version":3,"file":"evm.types.d.ts","sourceRoot":"","sources":["../../../client/evm/evm.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,IAAI,OAAO,EACrB,gBAAgB,IAAI,aAAa,EACjC,eAAe,IAAI,YAAY,EAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CA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Ac;IAC7B,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iBAAiB;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,+BAA+B;IAC/B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,0BAA0B;IAC1B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -1,4 +1,4 @@
1
- import { SolanaClientInterface, Account, CreateAccountOptions, GetAccountOptions, ListAccountsOptions, RequestFaucetOptions, ListAccountsResult, SignatureResult, SignMessageOptions, SignTransactionOptions } from "./solana.types.js";
1
+ import { SolanaClientInterface, Account, CreateAccountOptions, GetAccountOptions, ListAccountsOptions, RequestFaucetOptions, ListAccountsResult, SignatureResult, SignMessageOptions, SignTransactionOptions, GetOrCreateAccountOptions } from "./solana.types.js";
2
2
  /**
3
3
  * The namespace containing all Solana methods.
4
4
  */
@@ -60,6 +60,22 @@ export declare class SolanaClient implements SolanaClientInterface {
60
60
  * ```
61
61
  */
62
62
  getAccount(options: GetAccountOptions): Promise<Account>;
63
+ /**
64
+ * Gets a Solana account by its address.
65
+ *
66
+ * @param {GetOrCreateAccountOptions} options - Parameters for getting or creating the Solana account.
67
+ * @param {string} options.name - The name of the account.
68
+ *
69
+ * @returns A promise that resolves to the account.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const account = await cdp.solana.getOrCreateAccount({
74
+ * name: "MyAccount",
75
+ * });
76
+ * ```
77
+ */
78
+ getOrCreateAccount(options: GetOrCreateAccountOptions): Promise<Account>;
63
79
  /**
64
80
  * Lists all Solana accounts.
65
81
  *
@@ -1 +1 @@
1
- {"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../client/solana/solana.ts"],"names":[],"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;;;;;;;;;;;;;;;;OA6BG;IACG,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAY9D;;;;;;;;;;;;;;OAcG;IACG,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0B9E;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAYlF;;;;;;;;;;;;;;;;;OAiBG;IACG,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IAW5E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAUxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC;CAajF"}
@@ -5,6 +5,7 @@ import { OpenApiSolanaMethods, SolanaAccount as OpenAPISolanaAccount } from "../
5
5
  export type SolanaClientInterface = Omit<typeof OpenApiSolanaMethods, "createSolanaAccount" | "getSolanaAccount" | "getSolanaAccountByName" | "listSolanaAccounts" | "requestSolanaFaucet" | "signSolanaMessage" | "signSolanaTransaction"> & {
6
6
  createAccount: (options: CreateAccountOptions) => Promise<Account>;
7
7
  getAccount: (options: GetAccountOptions) => Promise<Account>;
8
+ getOrCreateAccount: (options: GetOrCreateAccountOptions) => Promise<Account>;
8
9
  listAccounts: (options: ListAccountsOptions) => Promise<ListAccountsResult>;
9
10
  requestFaucet: (options: RequestFaucetOptions) => Promise<SignatureResult>;
10
11
  signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
@@ -32,6 +33,13 @@ export interface GetAccountOptions {
32
33
  /** The name of the account. */
33
34
  name?: string;
34
35
  }
36
+ /**
37
+ * Options for getting a Solana account.
38
+ */
39
+ export interface GetOrCreateAccountOptions {
40
+ /** The name of the account. */
41
+ name: string;
42
+ }
35
43
  /**
36
44
  * Options for listing Solana accounts.
37
45
  */
@@ -1 +1 @@
1
- {"version":3,"file":"solana.types.d.ts","sourceRoot":"","sources":["../../../client/solana/solana.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,aAAa,IAAI,oBAAoB,EACtC,MAAM,+BAA+B,CAAC;AACvC;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,OAAO,oBAAoB,EACzB,qBAAqB,GACrB,kBAAkB,GAClB,wBAAwB,GACxB,oBAAoB,GACpB,qBAAqB,GACrB,mBAAmB,GACnB,uBAAuB,CAC1B,GAAG;IACF,aAAa,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,UAAU,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7D,YAAY,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3E,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IACvE,eAAe,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CAChF,CAAC;AACF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,oBAAoB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oBAAoB;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;IACtB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,qBAAqB;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB"}
1
+ {"version":3,"file":"solana.types.d.ts","sourceRoot":"","sources":["../../../client/solana/solana.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAA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,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oBAAoB;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;IACtB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,qBAAqB;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,9 @@
1
+ import { TransactionRequestEIP1559 } from "../types/misc.js";
2
+ /**
3
+ * Serializes a transaction for the Coinbase API.
4
+ *
5
+ * @param transaction - The transaction to serialize.
6
+ * @returns The serialized transaction.
7
+ */
8
+ export declare function serializeEIP1559Transaction(transaction: TransactionRequestEIP1559): `0x02${string}`;
9
+ //# sourceMappingURL=serializeTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializeTransaction.d.ts","sourceRoot":"","sources":["../../utils/serializeTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,yBAAyB,mBAMjF"}
@@ -1,2 +1,2 @@
1
- export declare const version = "1.4.0";
1
+ export declare const version = "1.5.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,9 +1,12 @@
1
- import { serializeTransaction, TransactionSerializable } from "viem";
1
+ import { type Hex, type TransactionSerializable, serializeTransaction } from "viem";
2
2
 
3
- import { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
4
- import { EvmServerAccount } from "../types.js";
3
+ import { accountTransferStrategy } from "../../actions/evm/transfer/accountTransferStrategy.js";
4
+ import { transfer } from "../../actions/evm/transfer/transfer.js";
5
5
 
6
+ import type { TransferResult } from "../../actions/evm/transfer/types.js";
7
+ import type { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
6
8
  import type { Address, Hash } from "../../types/misc.js";
9
+ import type { EvmServerAccount } from "../types.js";
7
10
 
8
11
  /**
9
12
  * Options for converting a pre-existing EvmAccount to a EvmServerAccount.
@@ -32,26 +35,29 @@ export function toEvmServerAccount(
32
35
  const result = await apiClient.signEvmMessage(options.account.address, {
33
36
  message: message.toString(),
34
37
  });
35
- return result.signature as `0x${string}`;
38
+ return result.signature as Hex;
36
39
  },
37
40
 
38
41
  async sign(parameters: { hash: Hash }) {
39
42
  const result = await apiClient.signEvmHash(options.account.address, {
40
43
  hash: parameters.hash,
41
44
  });
42
- return result.signature as `0x${string}`;
45
+ return result.signature as Hex;
43
46
  },
44
47
 
45
48
  async signTransaction(transaction: TransactionSerializable) {
46
49
  const result = await apiClient.signEvmTransaction(options.account.address, {
47
50
  transaction: serializeTransaction(transaction),
48
51
  });
49
- return result.signedTransaction as `0x${string}`;
52
+ return result.signedTransaction as Hex;
50
53
  },
51
54
 
52
55
  async signTypedData() {
53
56
  throw new Error("Not implemented");
54
57
  },
58
+ async transfer(transferArgs): Promise<TransferResult> {
59
+ return transfer(apiClient, account, transferArgs, accountTransferStrategy);
60
+ },
55
61
  name: options.account.name,
56
62
  type: "evm-server",
57
63
  };
@@ -1,7 +1,13 @@
1
- import { EvmSmartAccount as EvmSmartAccountModel } from "../../openapi-client/index.js";
2
- import { EvmAccount, EvmSmartAccount } from "../types.js";
1
+ import { smartAccountTransferStrategy } from "../../actions/evm/transfer/smartAccountTransferStrategy.js";
2
+ import { transfer } from "../../actions/evm/transfer/transfer.js";
3
3
 
4
+ import type { TransferResult } from "../../actions/evm/transfer/types.js";
5
+ import type {
6
+ CdpOpenApiClientType,
7
+ EvmSmartAccount as EvmSmartAccountModel,
8
+ } from "../../openapi-client/index.js";
4
9
  import type { Address } from "../../types/misc.js";
10
+ import type { EvmAccount, EvmSmartAccount } from "../types.js";
5
11
 
6
12
  /**
7
13
  * Options for converting a pre-existing EvmSmartAccount and owner to a EvmSmartAccount
@@ -19,16 +25,22 @@ export type ToEvmSmartAccountOptions = {
19
25
  *
20
26
  * The owner must be the original owner of the evm smart account.
21
27
  *
28
+ * @param {CdpOpenApiClientType} apiClient - The API client.
22
29
  * @param {ToEvmSmartAccountOptions} options - Configuration options.
23
30
  * @param {EvmSmartAccount} options.smartAccount - The deployed evm smart account.
24
31
  * @param {EvmAccount} options.owner - The owner which signs for the smart account.
25
32
  * @returns {EvmSmartAccount} A configured EvmSmartAccount instance ready for user operation submission.
26
- * @throws {Error} If the account is not an original owner of the smart account.
27
33
  */
28
- export function toEvmSmartAccount(options: ToEvmSmartAccountOptions): EvmSmartAccount {
34
+ export function toEvmSmartAccount(
35
+ apiClient: CdpOpenApiClientType,
36
+ options: ToEvmSmartAccountOptions,
37
+ ): EvmSmartAccount {
29
38
  const account: EvmSmartAccount = {
30
39
  address: options.smartAccount.address as Address,
31
40
  owners: [options.owner],
41
+ async transfer(transferArgs): Promise<TransferResult> {
42
+ return transfer(apiClient, account, transferArgs, smartAccountTransferStrategy);
43
+ },
32
44
  name: options.smartAccount.name,
33
45
  type: "evm-smart",
34
46
  };
package/accounts/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { SignableMessage, TransactionSerializable, TypedData, TypedDataDefinition } from "viem";
2
2
 
3
+ import { Actions } from "../actions/evm/types.js";
3
4
  import { Prettify } from "../types/utils.js";
4
5
 
5
6
  import type { Hash, Hex, Address } from "../types/misc.js";
@@ -30,24 +31,27 @@ export type EvmAccount = {
30
31
  * Server-managed ethereum account
31
32
  */
32
33
  export type EvmServerAccount = Prettify<
33
- EvmAccount & {
34
- /** Optional name for the server account. */
35
- name?: string;
36
- /** Indicates this is a server-managed account. */
37
- type: "evm-server";
38
- }
34
+ EvmAccount &
35
+ Actions & {
36
+ /** Optional name for the server account. */
37
+ name?: string;
38
+ /** Indicates this is a server-managed account. */
39
+ type: "evm-server";
40
+ }
39
41
  >;
40
42
 
41
43
  /**
42
44
  * Ethereum smart account which supports account abstraction features like user operations, batch transactions, and paymaster.
43
45
  */
44
- export type EvmSmartAccount = {
45
- /** The smart account's address. */
46
- address: Address;
47
- /** The name of the smart account. */
48
- name?: string;
49
- /** Array of accounts that own and can sign for the smart account (currently only supports one owner but will be extended to support multiple owners in the future). */
50
- owners: EvmAccount[];
51
- /** Identifier for the smart account type. */
52
- type: "evm-smart";
53
- };
46
+ export type EvmSmartAccount = Prettify<
47
+ {
48
+ /** The smart account's address. */
49
+ address: Address;
50
+ /** The name of the smart account. */
51
+ name?: string;
52
+ /** Array of accounts that own and can sign for the smart account (currently only supports one owner but will be extended to support multiple owners in the future). */
53
+ owners: EvmAccount[];
54
+ /** Identifier for the smart account type. */
55
+ type: "evm-smart";
56
+ } & Actions
57
+ >;
@@ -0,0 +1,84 @@
1
+ import {
2
+ encodeFunctionData,
3
+ erc20Abi,
4
+ Hex,
5
+ TransactionReceipt,
6
+ WaitForTransactionReceiptTimeoutError,
7
+ } from "viem";
8
+
9
+ import { TransferExecutionStrategy } from "./types.js";
10
+ import { getErc20Address } from "./utils.js";
11
+ import { EvmAccount } from "../../../accounts/types.js";
12
+ import { serializeEIP1559Transaction } from "../../../utils/serializeTransaction.js";
13
+
14
+ export const accountTransferStrategy: TransferExecutionStrategy<EvmAccount> = {
15
+ executeTransfer: async ({ apiClient, from, transferArgs, to, value }) => {
16
+ const transactionHash = await (async () => {
17
+ if (transferArgs.token === "eth") {
18
+ const result = await apiClient.sendEvmTransaction(from.address, {
19
+ transaction: serializeEIP1559Transaction({
20
+ value,
21
+ to,
22
+ }),
23
+ network: transferArgs.network,
24
+ });
25
+ return result.transactionHash as Hex;
26
+ } else {
27
+ const erc20Address = getErc20Address(transferArgs.token, transferArgs.network);
28
+
29
+ await apiClient.sendEvmTransaction(from.address, {
30
+ transaction: serializeEIP1559Transaction({
31
+ to: erc20Address,
32
+ data: encodeFunctionData({
33
+ abi: erc20Abi,
34
+ functionName: "approve",
35
+ args: [to, value],
36
+ }),
37
+ }),
38
+ network: transferArgs.network,
39
+ });
40
+
41
+ const result = await apiClient.sendEvmTransaction(from.address, {
42
+ transaction: serializeEIP1559Transaction({
43
+ to: erc20Address,
44
+ data: encodeFunctionData({
45
+ abi: erc20Abi,
46
+ functionName: "transfer",
47
+ args: [to, value],
48
+ }),
49
+ }),
50
+ network: transferArgs.network,
51
+ });
52
+
53
+ return result.transactionHash as Hex;
54
+ }
55
+ })();
56
+
57
+ return transactionHash;
58
+ },
59
+
60
+ waitForResult: async ({ publicClient, hash }) => {
61
+ let receipt: TransactionReceipt;
62
+ try {
63
+ receipt = await publicClient.waitForTransactionReceipt({
64
+ hash,
65
+ });
66
+ } catch (error) {
67
+ if (error instanceof WaitForTransactionReceiptTimeoutError) {
68
+ throw new Error(
69
+ `Transaction timed out. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`,
70
+ );
71
+ } else {
72
+ throw error;
73
+ }
74
+ }
75
+
76
+ if (receipt.status === "success") {
77
+ return { status: receipt.status, transactionHash: hash };
78
+ } else {
79
+ throw new Error(
80
+ `Transaction failed. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`,
81
+ );
82
+ }
83
+ },
84
+ };
@@ -0,0 +1,70 @@
1
+ import { encodeFunctionData, erc20Abi } from "viem";
2
+
3
+ import { TransferExecutionStrategy } from "./types.js";
4
+ import { getErc20Address } from "./utils.js";
5
+ import { EvmSmartAccount } from "../../../accounts/types.js";
6
+ import { sendUserOperation } from "../sendUserOperation.js";
7
+ import { waitForUserOperation } from "../waitForUserOperation.js";
8
+
9
+ export const smartAccountTransferStrategy: TransferExecutionStrategy<EvmSmartAccount> = {
10
+ executeTransfer: async ({ apiClient, from, transferArgs, to, value }) => {
11
+ const userOpHash = await (async () => {
12
+ if (transferArgs.token === "eth") {
13
+ const result = await sendUserOperation(apiClient, from, {
14
+ network: transferArgs.network,
15
+ calls: [
16
+ {
17
+ to,
18
+ value,
19
+ data: "0x",
20
+ },
21
+ ],
22
+ });
23
+ return result.userOpHash;
24
+ } else {
25
+ const erc20Address = getErc20Address(transferArgs.token, transferArgs.network);
26
+
27
+ const result = await sendUserOperation(apiClient, from, {
28
+ network: transferArgs.network,
29
+ calls: [
30
+ {
31
+ to: erc20Address,
32
+ data: encodeFunctionData({
33
+ abi: erc20Abi,
34
+ functionName: "approve",
35
+ args: [to, value],
36
+ }),
37
+ },
38
+ {
39
+ to: erc20Address,
40
+ data: encodeFunctionData({
41
+ abi: erc20Abi,
42
+ functionName: "transfer",
43
+ args: [to, value],
44
+ }),
45
+ },
46
+ ],
47
+ });
48
+
49
+ return result.userOpHash;
50
+ }
51
+ })();
52
+
53
+ return userOpHash;
54
+ },
55
+
56
+ waitForResult: async ({ apiClient, publicClient, from, hash }) => {
57
+ const result = await waitForUserOperation(apiClient, {
58
+ smartAccountAddress: from.address,
59
+ userOpHash: hash,
60
+ });
61
+
62
+ if (result.status === "complete") {
63
+ return { status: "success", transactionHash: hash };
64
+ } else {
65
+ throw new Error(
66
+ `Transaction failed. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`,
67
+ );
68
+ }
69
+ },
70
+ };