@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
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../accounts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAEhG,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,IAAI,EAAE,G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QAAQ,CACpC;IACE,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uKAAuK;IACvK,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,6CAA6C;IAC7C,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CACZ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { TransferExecutionStrategy } from "./types.js";
2
+ import { EvmAccount } from "../../../accounts/types.js";
3
+ export declare const accountTransferStrategy: TransferExecutionStrategy<EvmAccount>;
4
+ //# sourceMappingURL=accountTransferStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accountTransferStrategy.d.ts","sourceRoot":"","sources":["../../../../actions/evm/transfer/accountTransferStrategy.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,eAAO,MAAM,uBAAuB,EAAE,yBAAyB,CAAC,UAAU,CAsEzE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { TransferExecutionStrategy } from "./types.js";
2
+ import { EvmSmartAccount } from "../../../accounts/types.js";
3
+ export declare const smartAccountTransferStrategy: TransferExecutionStrategy<EvmSmartAccount>;
4
+ //# sourceMappingURL=smartAccountTransferStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartAccountTransferStrategy.d.ts","sourceRoot":"","sources":["../../../../actions/evm/transfer/smartAccountTransferStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAI7D,eAAO,MAAM,4BAA4B,EAAE,yBAAyB,CAAC,eAAe,CA6DnF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { TransferResult, TransferOptions, TransferExecutionStrategy } from "./types.js";
2
+ import { EvmAccount, EvmSmartAccount } from "../../../accounts/types.js";
3
+ import { CdpOpenApiClientType } from "../../../openapi-client/index.js";
4
+ /**
5
+ * Transfer an amount of a token from an account to another account.
6
+ *
7
+ * @param apiClient - The client to use to send the transaction.
8
+ * @param from - The account to send the transaction from.
9
+ * @param transferArgs - The options for the transfer.
10
+ * @param transferStrategy - The strategy to use to execute the transfer.
11
+ * @returns The result of the transfer.
12
+ */
13
+ export declare function transfer<T extends EvmAccount | EvmSmartAccount>(apiClient: CdpOpenApiClientType, from: T, transferArgs: TransferOptions, transferStrategy: TransferExecutionStrategy<T>): Promise<TransferResult>;
14
+ //# sourceMappingURL=transfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../../../actions/evm/transfer/transfer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,CAAC,SAAS,UAAU,GAAG,eAAe,EACnE,SAAS,EAAE,oBAAoB,EAC/B,IAAI,EAAE,CAAC,EACP,YAAY,EAAE,eAAe,EAC7B,gBAAgB,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,cAAc,CAAC,CAiDzB"}
@@ -0,0 +1,71 @@
1
+ import { Hex, TransactionReceipt, Address, PublicClient, Chain, Transport } from "viem";
2
+ import { CdpOpenApiClientType, EvmAccount, EvmUserOperationNetwork, SendEvmTransactionBodyNetwork } from "../../../openapi-client/index.js";
3
+ /**
4
+ * The network to transfer the token on.
5
+ */
6
+ export type Network = SendEvmTransactionBodyNetwork | EvmUserOperationNetwork;
7
+ /**
8
+ * The options for the transfer.
9
+ */
10
+ export type TransferOptions = {
11
+ /** The account to transfer the token to. */
12
+ to: EvmAccount | Address;
13
+ /**
14
+ * The amount of the token to transfer.
15
+ * If a string is provided, it will be parsed into a bigint based on the token's decimals.
16
+ */
17
+ amount: bigint | string;
18
+ /** The token to transfer. Can be a contract address or a predefined token name. */
19
+ token: "eth" | "usdc" | Hex;
20
+ /** The network to transfer the token on. */
21
+ network: Network;
22
+ };
23
+ /**
24
+ * The result of the transfer.
25
+ */
26
+ export type TransferResult = {
27
+ /** The status of the transaction. */
28
+ status: TransactionReceipt["status"];
29
+ /** The transaction hash of the transfer. */
30
+ transactionHash: Hex;
31
+ };
32
+ /**
33
+ * A strategy for executing a transfer.
34
+ */
35
+ export interface TransferExecutionStrategy<T> {
36
+ /**
37
+ * Executes the transfer.
38
+ *
39
+ * @param args - The arguments for the transfer.
40
+ * @param args.apiClient - The API client to use for the transfer.
41
+ * @param args.from - The account to transfer the token from.
42
+ * @param args.transferArgs - The arguments for the transfer.
43
+ * @param args.to - The account to transfer the token to.
44
+ * @param args.value - The value of the transfer.
45
+ * @returns The transaction hash of the transfer.
46
+ */
47
+ executeTransfer(args: {
48
+ apiClient: CdpOpenApiClientType;
49
+ from: T;
50
+ transferArgs: TransferOptions;
51
+ to: Address;
52
+ value: bigint;
53
+ }): Promise<Hex>;
54
+ /**
55
+ * Waits for the result of the transfer.
56
+ *
57
+ * @param args - The arguments for the transfer.
58
+ * @param args.apiClient - The API client to use for the transfer.
59
+ * @param args.publicClient - The public client to use for the transfer.
60
+ * @param args.from - The account to transfer the token from.
61
+ * @param args.hash - The transaction hash of the transfer.
62
+ * @returns The result of the transfer.
63
+ */
64
+ waitForResult(args: {
65
+ apiClient: CdpOpenApiClientType;
66
+ publicClient: PublicClient<Transport, Chain>;
67
+ from: T;
68
+ hash: Hex;
69
+ }): Promise<TransferResult>;
70
+ }
71
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../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