@coinbase/cdp-sdk 1.2.0 → 1.3.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 +12 -0
- package/README.md +88 -1
- package/_cjs/analytics.js +25 -6
- package/_cjs/analytics.js.map +1 -1
- package/_cjs/auth/hooks/axios/withAuth.js +1 -0
- package/_cjs/auth/hooks/axios/withAuth.js.map +1 -1
- package/_cjs/client/cdp.js +2 -0
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/evm/evm.js +119 -0
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/openapi-client/cdpApiClient.js +16 -50
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
- package/_cjs/openapi-client/errors.js +38 -3
- package/_cjs/openapi-client/errors.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +12 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +39 -4
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +15 -1
- package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +1 -0
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js +15 -0
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -0
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.msw.js +45 -0
- package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.msw.js.map +1 -0
- package/_cjs/openapi-client/generated/faucets/faucets.js +2 -1
- package/_cjs/openapi-client/generated/faucets/faucets.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +2 -1
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/index.js +4 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/analytics.js +23 -6
- package/_esm/analytics.js.map +1 -1
- package/_esm/auth/hooks/axios/withAuth.js +1 -0
- package/_esm/auth/hooks/axios/withAuth.js.map +1 -1
- package/_esm/client/cdp.js +2 -0
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/evm/evm.js +119 -0
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/openapi-client/cdpApiClient.js +13 -17
- package/_esm/openapi-client/cdpApiClient.js.map +1 -1
- package/_esm/openapi-client/errors.js +35 -2
- package/_esm/openapi-client/errors.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +11 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +37 -3
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +12 -0
- package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +1 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js +11 -0
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -0
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.msw.js +39 -0
- package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.msw.js.map +1 -0
- package/_esm/openapi-client/generated/faucets/faucets.js +2 -1
- package/_esm/openapi-client/generated/faucets/faucets.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +2 -1
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/index.js +4 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/analytics.d.ts +15 -0
- package/_types/analytics.d.ts.map +1 -1
- package/_types/auth/hooks/axios/withAuth.d.ts.map +1 -1
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +83 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +100 -4
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
- package/_types/openapi-client/errors.d.ts +28 -1
- package/_types/openapi-client/errors.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +87 -2
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +32 -4
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +3 -1
- package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +1 -0
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts +20 -0
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts.map +1 -0
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.msw.d.ts +6 -0
- package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.msw.d.ts.map +1 -0
- package/_types/openapi-client/generated/faucets/faucets.d.ts +2 -1
- package/_types/openapi-client/generated/faucets/faucets.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +2 -1
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +5 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/types/misc.d.ts +37 -0
- package/_types/types/misc.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/analytics.ts +26 -7
- package/auth/hooks/axios/withAuth.ts +1 -0
- package/client/cdp.ts +3 -0
- package/client/evm/evm.ts +134 -1
- package/client/evm/evm.types.ts +113 -8
- package/openapi-client/cdpApiClient.ts +28 -21
- package/openapi-client/errors.ts +37 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +103 -2
- package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +29 -0
- package/openapi-client/generated/evm-accounts/evm-accounts.ts +47 -3
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +1 -0
- package/openapi-client/generated/evm-token-balances/evm-token-balances.msw.ts +57 -0
- package/openapi-client/generated/evm-token-balances/evm-token-balances.ts +37 -0
- package/openapi-client/generated/faucets/faucets.ts +2 -1
- package/openapi-client/generated/index.msw.ts +2 -1
- package/openapi-client/index.ts +4 -0
- package/package.json +1 -1
- package/types/misc.ts +39 -0
- package/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm-smart-accounts.d.ts","sourceRoot":"","sources":["../../../../openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,KAAK,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,0BAA0B,EACnC,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,qCAM/C,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,2BAA2B,yBAAyB,EACpD,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,6BAW/C,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,MAAM,EACf,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,6BAM/C,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,EACf,0BAA0B,wBAAwB,EAClD,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,8BAW/C,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,MAAM,EACf,YAAY,MAAM,EAClB,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,8BAM/C,CAAC;AACF
|
|
1
|
+
{"version":3,"file":"evm-smart-accounts.d.ts","sourceRoot":"","sources":["../../../../openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,KAAK,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,0BAA0B,EACnC,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,qCAM/C,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,2BAA2B,yBAAyB,EACpD,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,6BAW/C,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,MAAM,EACf,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,6BAM/C,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,EACf,0BAA0B,wBAAwB,EAClD,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,8BAW/C,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,MAAM,EACf,YAAY,MAAM,EAClB,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,8BAM/C,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,EACf,YAAY,MAAM,EAClB,uBAAuB,qBAAqB,EAC5C,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,8BAW/C,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,WAAW,CAClD,OAAO,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CACjD,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG,WAAW,CACnD,OAAO,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAClD,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;AACnG,MAAM,MAAM,0BAA0B,GAAG,WAAW,CAClD,OAAO,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CACjD,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAC/F,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type { ListEvmTokenBalances200, ListEvmTokenBalancesNetwork, ListEvmTokenBalancesParams } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
9
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
10
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
11
|
+
/**
|
|
12
|
+
* Lists the token balances of an EVM address on a given network. The balances include ERC-20 tokens and the native gas token (usually ETH). The response is paginated, and by default, returns 20 balances per page.
|
|
13
|
+
|
|
14
|
+
**Note:** This endpoint is still under development and does not yet provide strong freshness guarantees. Specifically, balances of new tokens can, on occasion, take up to ~30 seconds to appear, while balances of tokens already belonging to an address will generally be close to chain tip. Freshness of new token balances will improve over the coming weeks.
|
|
15
|
+
* @summary List EVM token balances
|
|
16
|
+
*/
|
|
17
|
+
export declare const listEvmTokenBalances: (network: ListEvmTokenBalancesNetwork, address: string, params?: ListEvmTokenBalancesParams, options?: SecondParameter<typeof cdpApiClient>) => Promise<ListEvmTokenBalances200>;
|
|
18
|
+
export type ListEvmTokenBalancesResult = NonNullable<Awaited<ReturnType<typeof listEvmTokenBalances>>>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=evm-token-balances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm-token-balances.d.ts","sourceRoot":"","sources":["../../../../openapi-client/generated/evm-token-balances/evm-token-balances.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC3B,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,KAAK,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,2BAA2B,EACpC,SAAS,MAAM,EACf,SAAS,0BAA0B,EACnC,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,qCAM/C,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,WAAW,CAClD,OAAO,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CACjD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { http } from "msw";
|
|
2
|
+
import type { ListEvmTokenBalances200 } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
3
|
+
export declare const getListEvmTokenBalancesResponseMock: () => ListEvmTokenBalances200;
|
|
4
|
+
export declare const getListEvmTokenBalancesMockHandler: (overrideResponse?: ListEvmTokenBalances200 | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ListEvmTokenBalances200> | ListEvmTokenBalances200)) => import("msw").HttpHandler;
|
|
5
|
+
export declare const getEvmTokenBalancesMock: () => import("msw").HttpHandler[];
|
|
6
|
+
//# sourceMappingURL=evm-token-balances.msw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm-token-balances.msw.d.ts","sourceRoot":"","sources":["../../../../openapi-client/generated/evm-token-balances/evm-token-balances.msw.ts"],"names":[],"mappings":"AASA,OAAO,EAAuB,IAAI,EAAE,MAAM,KAAK,CAAC;AAGhD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAE3F,eAAO,MAAM,mCAAmC,QAAO,uBAkBrD,CAAC;AAEH,eAAO,MAAM,kCAAkC,GAC7C,mBACI,uBAAuB,GACvB,CAAC,CACC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAChD,OAAO,CAAC,uBAAuB,CAAC,GAAG,uBAAuB,CAAC,8BAgBrE,CAAC;AACF,eAAO,MAAM,uBAAuB,mCAA+C,CAAC"}
|
|
@@ -19,7 +19,7 @@ A single blockchain address cannot exceed the specified limits, even if multiple
|
|
|
19
19
|
|
|
20
20
|
| Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits|
|
|
21
21
|
|:-----:|:-------------------------:|:--------------------------------:|
|
|
22
|
-
| ETH | 0.0001 ETH | 0.
|
|
22
|
+
| ETH | 0.0001 ETH | 0.1 ETH |
|
|
23
23
|
| USDC | 1 USDC | 10 USDC |
|
|
24
24
|
| EURC | 1 EURC | 10 EURC |
|
|
25
25
|
| cbBTC | 0.0001 cbBTC | 0.001 cbBTC |
|
|
@@ -39,6 +39,7 @@ A single blockchain address cannot exceed the specified limits, even if multiple
|
|
|
39
39
|
| Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits|
|
|
40
40
|
|:-----:|:-------------------------:|:--------------------------------:|
|
|
41
41
|
| SOL | 0.00125 SOL | 0.0125 SOL |
|
|
42
|
+
| USDC | 1 USDC | 10 USDC |
|
|
42
43
|
|
|
43
44
|
* @summary Request funds on Solana devnet
|
|
44
45
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faucets.d.ts","sourceRoot":"","sources":["../../../../openapi-client/generated/faucets/faucets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,KAAK,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,GAC3B,sBAAsB,oBAAoB,EAC1C,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,iCAW/C,CAAC;AACF
|
|
1
|
+
{"version":3,"file":"faucets.d.ts","sourceRoot":"","sources":["../../../../openapi-client/generated/faucets/faucets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,KAAK,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,GAC3B,sBAAsB,oBAAoB,EAC1C,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,iCAW/C,CAAC;AACF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,GAC9B,yBAAyB,uBAAuB,EAChD,UAAU,eAAe,CAAC,OAAO,YAAY,CAAC,oCAW/C,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAC/F,MAAM,MAAM,yBAAyB,GAAG,WAAW,CACjD,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAChD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./evm-accounts/evm-accounts.msw.js";
|
|
2
|
-
export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
|
|
3
2
|
export * from "./faucets/faucets.msw.js";
|
|
3
|
+
export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
|
|
4
|
+
export * from "./evm-token-balances/evm-token-balances.msw.js";
|
|
4
5
|
export * from "./solana-accounts/solana-accounts.msw.js";
|
|
5
6
|
//# sourceMappingURL=index.msw.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.msw.d.ts","sourceRoot":"","sources":["../../../openapi-client/generated/index.msw.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,
|
|
1
|
+
{"version":3,"file":"index.msw.d.ts","sourceRoot":"","sources":["../../../openapi-client/generated/index.msw.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./generated/coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
2
2
|
export * from "./generated/evm-accounts/evm-accounts.js";
|
|
3
3
|
export * from "./generated/evm-smart-accounts/evm-smart-accounts.js";
|
|
4
|
+
export * from "./generated/evm-token-balances/evm-token-balances.js";
|
|
4
5
|
export * from "./generated/solana-accounts/solana-accounts.js";
|
|
5
6
|
export * from "./generated/faucets/faucets.js";
|
|
6
7
|
export declare const CdpOpenApiClient: {
|
|
@@ -13,6 +14,7 @@ export declare const CdpOpenApiClient: {
|
|
|
13
14
|
getSolanaAccountByName: (name: string, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SolanaAccount>;
|
|
14
15
|
signSolanaTransaction: (address: string, signSolanaTransactionBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignSolanaTransactionBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignSolanaTransaction200>;
|
|
15
16
|
signSolanaMessage: (address: string, signSolanaMessageBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignSolanaMessageBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignSolanaMessage200>;
|
|
17
|
+
listEvmTokenBalances: (network: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmTokenBalancesNetwork, address: string, params?: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmTokenBalancesParams, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmTokenBalances200>;
|
|
16
18
|
listEvmSmartAccounts: (params?: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmSmartAccountsParams, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmSmartAccounts200>;
|
|
17
19
|
createEvmSmartAccount: (createEvmSmartAccountBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").CreateEvmSmartAccountBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmSmartAccount>;
|
|
18
20
|
getEvmSmartAccount: (address: string, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmSmartAccount>;
|
|
@@ -23,12 +25,14 @@ export declare const CdpOpenApiClient: {
|
|
|
23
25
|
createEvmAccount: (createEvmAccountBody?: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").CreateEvmAccountBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmAccount>;
|
|
24
26
|
getEvmAccount: (address: string, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmAccount>;
|
|
25
27
|
getEvmAccountByName: (name: string, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmAccount>;
|
|
28
|
+
sendEvmTransaction: (address: string, sendEvmTransactionBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SendEvmTransactionBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SendEvmTransaction200>;
|
|
26
29
|
signEvmTransaction: (address: string, signEvmTransactionBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmTransactionBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmTransaction200>;
|
|
27
30
|
signEvmHash: (address: string, signEvmHashBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmHashBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmHash200>;
|
|
28
31
|
signEvmMessage: (address: string, signEvmMessageBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmMessageBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmMessage200>;
|
|
29
32
|
};
|
|
30
33
|
export declare const OpenApiEvmMethods: {
|
|
31
34
|
requestEvmFaucet: (requestEvmFaucetBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").RequestEvmFaucetBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").RequestEvmFaucet200>;
|
|
35
|
+
listEvmTokenBalances: (network: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmTokenBalancesNetwork, address: string, params?: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmTokenBalancesParams, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmTokenBalances200>;
|
|
32
36
|
listEvmSmartAccounts: (params?: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmSmartAccountsParams, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").ListEvmSmartAccounts200>;
|
|
33
37
|
createEvmSmartAccount: (createEvmSmartAccountBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").CreateEvmSmartAccountBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmSmartAccount>;
|
|
34
38
|
getEvmSmartAccount: (address: string, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmSmartAccount>;
|
|
@@ -39,6 +43,7 @@ export declare const OpenApiEvmMethods: {
|
|
|
39
43
|
createEvmAccount: (createEvmAccountBody?: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").CreateEvmAccountBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmAccount>;
|
|
40
44
|
getEvmAccount: (address: string, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmAccount>;
|
|
41
45
|
getEvmAccountByName: (name: string, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").EvmAccount>;
|
|
46
|
+
sendEvmTransaction: (address: string, sendEvmTransactionBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SendEvmTransactionBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SendEvmTransaction200>;
|
|
42
47
|
signEvmTransaction: (address: string, signEvmTransactionBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmTransactionBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmTransaction200>;
|
|
43
48
|
signEvmHash: (address: string, signEvmHashBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmHashBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmHash200>;
|
|
44
49
|
signEvmMessage: (address: string, signEvmMessageBody: import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmMessageBody, options?: string | undefined) => Promise<import("./generated/coinbaseDeveloperPlatformAPIs.schemas.js").SignEvmMessage200>;
|
|
@@ -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,gDAAgD,CAAC;AAC/D,cAAc,gCAAgC,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,sDAAsD,CAAC;AACrE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gCAAgC,CAAC;AAS/C,eAAO,MAAM,gBAAgB;;uBAsB8Q,yGAA6C,EAAC,4BAAiD;0BAA2gC,+GAAmD,EAAC,4BAAiD;yBAhBh/C,gGAGmB,EAAE,4BAGpB;0BAUQ,gHAAoD,EAAC,4BAAiD;uBAAmW,eAAkB,EAAC,4BAAiD;6BAAgQ,YAAe,EAAC,4BAAiD;4BAAwvB,eAAkB,EAAC,mHAAuD,EAAC,4BAAiD;wBAAijB,eAAkB,EAAC,2GAA+C,EAAC,4BAAiD;2BAJ/1E,mGAGjB,EAAE,eAAiB,EAAC,kGACtB,EAAC,4BAAiD;2BAtBhD,kGAEN,EAAC,4BAEG;4BAciB,mHAGD,EAAC,4BACX;yBAA0W,eAAkB,EAAC,4BAAiD;2BAAqS,eAAkB,EAAC,iHAAqD,EAAC,4BAAiD;uBAAuX,eAAkB,EAAC,kBAAqB,EAAC,4BAAiD;wBAA2f,eAAkB,EAAC,kBAAqB,EAAC,2GAA+C,EAAC,4BAAiD;sBAlB/6D,6FAEI,EAAC,4BAIH;uBAWqB,0GACd,EAAC,4BAAiD;oBAAmV,eAAe,EAAC,4BAA+C;0BAAoO,YAAe,EAAC,4BAAiD;yBAA68D,eAAkB,EAAC,6GAAiD,EAAC,4BAAiD;yBAA8wB,eAAkB,EAAC,6GAAiD,EAAC,4BAAiD;kBAAgY,eAAkB,EAAC,+FAAmC,EAAC,4BAAiD;qBAAqjB,eAAkB,EAAC,qGAAyC,EAAC,4BAAiD;CAfr0J,CAAC;AAEF,eAAO,MAAM,iBAAiB;;2BASH,mGAGjB,EAAE,eAAiB,EAAC,kGACtB,EAAC,4BAAiD;2BAtBhD,kGAEN,EAAC,4BAEG;4BAciB,mHAGD,EAAC,4BACX;yBAA0W,eAAkB,EAAC,4BAAiD;2BAAqS,eAAkB,EAAC,iHAAqD,EAAC,4BAAiD;uBAAuX,eAAkB,EAAC,kBAAqB,EAAC,4BAAiD;wBAA2f,eAAkB,EAAC,kBAAqB,EAAC,2GAA+C,EAAC,4BAAiD;sBAlB/6D,6FAEI,EAAC,4BAIH;uBAWqB,0GACd,EAAC,4BAAiD;oBAAmV,eAAe,EAAC,4BAA+C;0BAAoO,YAAe,EAAC,4BAAiD;yBAA68D,eAAkB,EAAC,6GAAiD,EAAC,4BAAiD;yBAA8wB,eAAkB,EAAC,6GAAiD,EAAC,4BAAiD;kBAAgY,eAAkB,EAAC,+FAAmC,EAAC,4BAAiD;qBAAqjB,eAAkB,EAAC,qGAAyC,EAAC,4BAAiD;CARr0J,CAAC;AAEF,eAAO,MAAM,oBAAoB;;yBAVvB,gGAGmB,EAAE,4BAGpB;0BAUQ,gHAAoD,EAAC,4BAAiD;uBAAmW,eAAkB,EAAC,4BAAiD;6BAAgQ,YAAe,EAAC,4BAAiD;4BAAwvB,eAAkB,EAAC,mHAAuD,EAAC,4BAAiD;wBAAijB,eAAkB,EAAC,2GAA+C,EAAC,4BAAiD;CAHz3E,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,gBAAgB,CAAC"}
|
package/_types/types/misc.d.ts
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
export type Hex = `0x${string}`;
|
|
2
2
|
export type Hash = `0x${string}`;
|
|
3
3
|
export type Address = `0x${string}`;
|
|
4
|
+
export type AccessList = readonly {
|
|
5
|
+
address: Address;
|
|
6
|
+
storageKeys: readonly Hex[];
|
|
7
|
+
}[];
|
|
8
|
+
export type TransactionRequestEIP1559 = {
|
|
9
|
+
/** The address of the contract or account to send the transaction to. */
|
|
10
|
+
to: Address;
|
|
11
|
+
/** The amount of ETH, in wei, to send with the transaction. */
|
|
12
|
+
value?: bigint | undefined;
|
|
13
|
+
/** The data to send with the transaction; only used for contract calls. */
|
|
14
|
+
data?: Hex | undefined;
|
|
15
|
+
/** The amount of gas to use for the transaction. */
|
|
16
|
+
gas?: bigint | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The nonce to use for the transaction.
|
|
19
|
+
* If not provided, the API will assign a nonce to the transaction based on the current state of the account.
|
|
20
|
+
*/
|
|
21
|
+
nonce?: number | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The maximum fee per gas to use for the transaction.
|
|
24
|
+
* If not provided, the API will estimate a value based on current network conditions.
|
|
25
|
+
*/
|
|
26
|
+
maxFeePerGas?: bigint | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The maximum priority fee per gas to use for the transaction.
|
|
29
|
+
* If not provided, the API will estimate a value based on current network conditions.
|
|
30
|
+
*/
|
|
31
|
+
maxPriorityFeePerGas?: bigint | undefined;
|
|
32
|
+
/** The access list to use for the transaction. */
|
|
33
|
+
accessList?: AccessList | undefined;
|
|
34
|
+
/** (Ignored) The value of the `chainId` field in the transaction is ignored. */
|
|
35
|
+
chainId?: number | undefined;
|
|
36
|
+
/** (Ignored) Ignored in favor of the account address that is sending the transaction. */
|
|
37
|
+
from?: Address | undefined;
|
|
38
|
+
/** (Ignored) The transaction type is always `eip1559`. */
|
|
39
|
+
type?: "eip1559" | undefined;
|
|
40
|
+
};
|
|
4
41
|
//# sourceMappingURL=misc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../types/misc.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAChC,MAAM,MAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;AACjC,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../types/misc.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAChC,MAAM,MAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;AACjC,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG,SAAS;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,SAAS,GAAG,EAAE,CAAC;CAC7B,EAAE,CAAC;AAEJ,MAAM,MAAM,yBAAyB,GAAG;IACtC,yEAAyE;IACzE,EAAE,EAAE,OAAO,CAAC;IACZ,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IACvB,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,kDAAkD;IAClD,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,yFAAyF;IACzF,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,0DAA0D;IAC1D,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC9B,CAAC"}
|
package/_types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.3.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/analytics.ts
CHANGED
|
@@ -28,6 +28,28 @@ type ErrorEventData = {
|
|
|
28
28
|
|
|
29
29
|
type EventData = ErrorEventData;
|
|
30
30
|
|
|
31
|
+
// This is a public client id for the analytics service
|
|
32
|
+
const publicClientId = "54f2ee2fb3d2b901a829940d70fbfc13";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* AnalyticsConfig singleton class for holding the API key ID
|
|
36
|
+
*/
|
|
37
|
+
export class AnalyticsConfig {
|
|
38
|
+
/**
|
|
39
|
+
* The API key ID
|
|
40
|
+
*/
|
|
41
|
+
public static apiKeyId: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Sets the API key ID
|
|
45
|
+
*
|
|
46
|
+
* @param apiKeyId - The API key ID
|
|
47
|
+
*/
|
|
48
|
+
public static set(apiKeyId: string): void {
|
|
49
|
+
AnalyticsConfig.apiKeyId = apiKeyId;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
31
53
|
/**
|
|
32
54
|
* Sends an analytics event to the default endpoint
|
|
33
55
|
*
|
|
@@ -38,12 +60,12 @@ export async function sendEvent(event: EventData): Promise<void> {
|
|
|
38
60
|
const timestamp = Date.now();
|
|
39
61
|
|
|
40
62
|
const enhancedEvent = {
|
|
63
|
+
user_id: AnalyticsConfig.apiKeyId,
|
|
41
64
|
event_type: event.name,
|
|
42
65
|
platform: "server",
|
|
66
|
+
timestamp,
|
|
43
67
|
event_properties: {
|
|
44
|
-
platform: "server",
|
|
45
68
|
project_name: "cdp-sdk",
|
|
46
|
-
time_start: timestamp,
|
|
47
69
|
cdp_sdk_language: "typescript",
|
|
48
70
|
...event,
|
|
49
71
|
},
|
|
@@ -56,6 +78,7 @@ export async function sendEvent(event: EventData): Promise<void> {
|
|
|
56
78
|
const checksum = md5(stringifiedEventData + uploadTime);
|
|
57
79
|
|
|
58
80
|
const analyticsServiceData = {
|
|
81
|
+
client: publicClientId,
|
|
59
82
|
e: stringifiedEventData,
|
|
60
83
|
checksum,
|
|
61
84
|
};
|
|
@@ -64,7 +87,7 @@ export async function sendEvent(event: EventData): Promise<void> {
|
|
|
64
87
|
const eventPath = "/amp";
|
|
65
88
|
const eventEndPoint = `${apiEndpoint}${eventPath}`;
|
|
66
89
|
|
|
67
|
-
|
|
90
|
+
await fetch(eventEndPoint, {
|
|
68
91
|
method: "POST",
|
|
69
92
|
mode: "no-cors",
|
|
70
93
|
headers: {
|
|
@@ -72,10 +95,6 @@ export async function sendEvent(event: EventData): Promise<void> {
|
|
|
72
95
|
},
|
|
73
96
|
body: JSON.stringify(analyticsServiceData),
|
|
74
97
|
});
|
|
75
|
-
|
|
76
|
-
if (!response.ok) {
|
|
77
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
78
|
-
}
|
|
79
98
|
}
|
|
80
99
|
|
|
81
100
|
/**
|
|
@@ -108,6 +108,7 @@ export function withAuth(axiosClient: AxiosInstance, options: AuthInterceptorOpt
|
|
|
108
108
|
headers: error.response?.headers,
|
|
109
109
|
data: error.response?.data,
|
|
110
110
|
message: error.message,
|
|
111
|
+
cause: error.cause,
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
console.error("Response Error:", errorDetails);
|
package/client/cdp.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AnalyticsConfig } from "../analytics.js";
|
|
1
2
|
import { CdpOpenApiClient } from "../openapi-client/index.js";
|
|
2
3
|
import { version } from "../version.js";
|
|
3
4
|
import { EvmClient } from "./evm/evm.js";
|
|
@@ -107,6 +108,8 @@ For more information, see: https://github.com/coinbase/cdp-sdk/blob/main/typescr
|
|
|
107
108
|
sourceVersion: version,
|
|
108
109
|
});
|
|
109
110
|
|
|
111
|
+
AnalyticsConfig.set(apiKeyId);
|
|
112
|
+
|
|
110
113
|
this.evm = new EvmClient();
|
|
111
114
|
this.solana = new SolanaClient();
|
|
112
115
|
}
|
package/client/evm/evm.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address } from "viem";
|
|
1
|
+
import { Address, serializeTransaction } from "viem";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
CreateServerAccountOptions,
|
|
@@ -23,6 +23,10 @@ import {
|
|
|
23
23
|
GetUserOperationOptions,
|
|
24
24
|
ListSmartAccountResult,
|
|
25
25
|
ListSmartAccountsOptions,
|
|
26
|
+
ListTokenBalancesOptions,
|
|
27
|
+
ListTokenBalancesResult,
|
|
28
|
+
SendTransactionOptions,
|
|
29
|
+
TransactionResult,
|
|
26
30
|
} from "./evm.types.js";
|
|
27
31
|
import { toEvmServerAccount } from "../../accounts/evm/toEvmServerAccount.js";
|
|
28
32
|
import { toEvmSmartAccount } from "../../accounts/evm/toEvmSmartAccount.js";
|
|
@@ -294,6 +298,65 @@ export class EvmClient implements EvmClientInterface {
|
|
|
294
298
|
};
|
|
295
299
|
}
|
|
296
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Lists CDP EVM token balances.
|
|
303
|
+
*
|
|
304
|
+
* @param {ListTokenBalancesOptions} options - Parameters for listing the token balances.
|
|
305
|
+
* @param {number} [options.pageSize] - The number of token balances to return.
|
|
306
|
+
* @param {string} [options.pageToken] - The page token to begin listing from.
|
|
307
|
+
* This is obtained by previous calls to this method.
|
|
308
|
+
*
|
|
309
|
+
* @returns A promise that resolves to an array of token balances, and a token to paginate through the token balances.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```ts
|
|
313
|
+
* const tokenBalances = await cdp.evm.listTokenBalances({
|
|
314
|
+
* address: "0x1234567890123456789012345678901234567890",
|
|
315
|
+
* network: "base-sepolia",
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* **With pagination**
|
|
321
|
+
* ```ts
|
|
322
|
+
* let page = await cdp.evm.listTokenBalances({
|
|
323
|
+
* address: "0x1234567890123456789012345678901234567890",
|
|
324
|
+
* network: "base-sepolia",
|
|
325
|
+
* });
|
|
326
|
+
*
|
|
327
|
+
* while (page.nextPageToken) {
|
|
328
|
+
* page = await cdp.evm.listTokenBalances({
|
|
329
|
+
* address: "0x1234567890123456789012345678901234567890",
|
|
330
|
+
* network: "base-sepolia",
|
|
331
|
+
* pageToken: page.nextPageToken,
|
|
332
|
+
* });
|
|
333
|
+
* }
|
|
334
|
+
*/
|
|
335
|
+
async listTokenBalances(options: ListTokenBalancesOptions): Promise<ListTokenBalancesResult> {
|
|
336
|
+
const response = await CdpOpenApiClient.listEvmTokenBalances(options.network, options.address, {
|
|
337
|
+
pageSize: options.pageSize,
|
|
338
|
+
pageToken: options.pageToken,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const balances = response.balances.map(balance => {
|
|
342
|
+
return {
|
|
343
|
+
token: {
|
|
344
|
+
network: balance.token.network,
|
|
345
|
+
contractAddress: balance.token.contractAddress as Address,
|
|
346
|
+
},
|
|
347
|
+
amount: {
|
|
348
|
+
amount: BigInt(balance.amount.amount),
|
|
349
|
+
decimals: BigInt(balance.amount.decimals),
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
return {
|
|
355
|
+
balances,
|
|
356
|
+
nextPageToken: response.nextPageToken,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
297
360
|
/**
|
|
298
361
|
* Lists CDP EVM smart accounts.
|
|
299
362
|
*
|
|
@@ -413,6 +476,76 @@ export class EvmClient implements EvmClientInterface {
|
|
|
413
476
|
};
|
|
414
477
|
}
|
|
415
478
|
|
|
479
|
+
/**
|
|
480
|
+
* Signs an EVM transaction and sends it to the specified network using the Coinbase API.
|
|
481
|
+
* This method handles nonce management and gas estimation automatically.
|
|
482
|
+
*
|
|
483
|
+
* @param {SendTransactionOptions} options - Configuration options for sending the transaction.
|
|
484
|
+
* @returns A promise that resolves to the transaction hash.
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* **Sending an RLP-encoded transaction**
|
|
488
|
+
* ```ts
|
|
489
|
+
* import { parseEther, serializeTransaction } from "viem";
|
|
490
|
+
* import { baseSepolia } from "viem/chains";
|
|
491
|
+
*
|
|
492
|
+
* const { transactionHash } = await cdp.evm.sendTransaction({
|
|
493
|
+
* address: account.address,
|
|
494
|
+
* transaction: serializeTransaction({
|
|
495
|
+
* to: "0x4252e0c9A3da5A2700e7d91cb50aEf522D0C6Fe8",
|
|
496
|
+
* value: parseEther("0.000001"),
|
|
497
|
+
* chainId: baseSepolia.id,
|
|
498
|
+
* // Fields below are optional, CDP API will populate them if omitted.
|
|
499
|
+
* // nonce
|
|
500
|
+
* // maxPriorityFeePerGas
|
|
501
|
+
* // maxFeePerGas
|
|
502
|
+
* // gas
|
|
503
|
+
* }),
|
|
504
|
+
* network: "base-sepolia",
|
|
505
|
+
* });
|
|
506
|
+
* ```
|
|
507
|
+
* @example
|
|
508
|
+
* **Sending an EIP-1559 transaction request object**
|
|
509
|
+
* ```ts
|
|
510
|
+
* const { transactionHash } = await cdp.evm.sendTransaction({
|
|
511
|
+
* address: account.address,
|
|
512
|
+
* transaction: {
|
|
513
|
+
* to: "0x4252e0c9A3da5A2700e7d91cb50aEf522D0C6Fe8",
|
|
514
|
+
* value: parseEther("0.000001"),
|
|
515
|
+
* // Fields below are optional, CDP API will populate them if omitted.
|
|
516
|
+
* // nonce
|
|
517
|
+
* // maxPriorityFeePerGas
|
|
518
|
+
* // maxFeePerGas
|
|
519
|
+
* // gas
|
|
520
|
+
* },
|
|
521
|
+
* network: "base-sepolia",
|
|
522
|
+
* });
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
async sendTransaction(options: SendTransactionOptions): Promise<TransactionResult> {
|
|
526
|
+
const { address, network, idempotencyKey } = options;
|
|
527
|
+
let transaction = options.transaction;
|
|
528
|
+
|
|
529
|
+
if (typeof transaction !== "string") {
|
|
530
|
+
transaction = serializeTransaction({
|
|
531
|
+
...transaction,
|
|
532
|
+
// chainId is ignored in favor of network
|
|
533
|
+
chainId: 1,
|
|
534
|
+
type: "eip1559",
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const result = await CdpOpenApiClient.sendEvmTransaction(
|
|
539
|
+
address,
|
|
540
|
+
{ transaction, network },
|
|
541
|
+
idempotencyKey,
|
|
542
|
+
);
|
|
543
|
+
|
|
544
|
+
return {
|
|
545
|
+
transactionHash: result.transactionHash as Hex,
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
416
549
|
/**
|
|
417
550
|
* Sends a user operation.
|
|
418
551
|
*
|
package/client/evm/evm.types.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Call, Calls } from "../../types/calls.js";
|
|
3
|
-
import { Address, Hex } from "../../types/misc.js";
|
|
4
|
-
import { WaitOptions } from "../../utils/wait.js";
|
|
5
|
-
|
|
6
|
-
import type {
|
|
1
|
+
import {
|
|
7
2
|
EvmAccount as Account,
|
|
8
3
|
EvmServerAccount as ServerAccount,
|
|
9
4
|
EvmSmartAccount as SmartAccount,
|
|
10
5
|
} from "../../accounts/types.js";
|
|
11
|
-
import
|
|
6
|
+
import { SendUserOperationReturnType } from "../../actions/evm/sendUserOperation.js";
|
|
7
|
+
import {
|
|
12
8
|
EvmUserOperationNetwork,
|
|
13
9
|
EvmUserOperationStatus,
|
|
14
10
|
OpenApiEvmMethods,
|
|
11
|
+
ListEvmTokenBalancesNetwork,
|
|
12
|
+
SendEvmTransactionBodyNetwork,
|
|
15
13
|
} from "../../openapi-client/index.js";
|
|
14
|
+
import { Call, Calls } from "../../types/calls.js";
|
|
15
|
+
import { Address, Hex, TransactionRequestEIP1559 } from "../../types/misc.js";
|
|
16
|
+
import { WaitOptions } from "../../utils/wait.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* The EvmClient type, where all OpenApiEvmMethods methods are wrapped.
|
|
@@ -25,15 +26,16 @@ export type EvmClientInterface = Omit<
|
|
|
25
26
|
| "getEvmAccountByName" // mapped to getAccount
|
|
26
27
|
| "getEvmSmartAccount" // mapped to getSmartAccount
|
|
27
28
|
| "getUserOperation"
|
|
28
|
-
| "listEVMBalances" // omit
|
|
29
29
|
| "listEvmAccounts" // mapped to listAccounts
|
|
30
30
|
| "listEvmSmartAccounts" // mapped to listSmartAccounts
|
|
31
|
+
| "listEvmTokenBalances" // mapped to listTokenBalances
|
|
31
32
|
| "prepareUserOperation"
|
|
32
33
|
| "requestEvmFaucet" // mapped to requestFaucet
|
|
33
34
|
| "sendUserOperation"
|
|
34
35
|
| "signEvmHash" // mapped to signHash
|
|
35
36
|
| "signEvmMessage" // mapped to signMessage
|
|
36
37
|
| "signEvmTransaction" // mapped to signTransaction
|
|
38
|
+
| "sendEvmTransaction" // mapped to sendTransaction
|
|
37
39
|
> & {
|
|
38
40
|
createAccount: (options: CreateServerAccountOptions) => Promise<ServerAccount>;
|
|
39
41
|
createSmartAccount: (options: CreateSmartAccountOptions) => Promise<SmartAccount>;
|
|
@@ -42,8 +44,10 @@ export type EvmClientInterface = Omit<
|
|
|
42
44
|
getUserOperation: (options: GetUserOperationOptions) => Promise<UserOperation>;
|
|
43
45
|
listAccounts: (options: ListServerAccountsOptions) => Promise<ListServerAccountResult>;
|
|
44
46
|
listSmartAccounts: (options: ListSmartAccountsOptions) => Promise<ListSmartAccountResult>;
|
|
47
|
+
listTokenBalances: (options: ListTokenBalancesOptions) => Promise<ListTokenBalancesResult>;
|
|
45
48
|
prepareUserOperation: (options: PrepareUserOperationOptions) => Promise<UserOperation>;
|
|
46
49
|
requestFaucet: (options: RequestFaucetOptions) => Promise<RequestFaucetResult>;
|
|
50
|
+
sendTransaction: (options: SendTransactionOptions) => Promise<TransactionResult>;
|
|
47
51
|
sendUserOperation: (options: SendUserOperationOptions) => Promise<SendUserOperationReturnType>;
|
|
48
52
|
signHash: (options: SignHashOptions) => Promise<SignatureResult>;
|
|
49
53
|
signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
|
|
@@ -230,6 +234,29 @@ export interface RequestFaucetResult {
|
|
|
230
234
|
transactionHash: Hex;
|
|
231
235
|
}
|
|
232
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Options for sending an EVM transaction.
|
|
239
|
+
*/
|
|
240
|
+
export interface SendTransactionOptions {
|
|
241
|
+
/** The address of the account. */
|
|
242
|
+
address: Address;
|
|
243
|
+
/**
|
|
244
|
+
* The transaction to send. The chainId is ignored in favor of the `network` field.
|
|
245
|
+
*
|
|
246
|
+
* This can be either:
|
|
247
|
+
* - An RLP-encoded transaction to sign and send, as a 0x-prefixed hex string, or
|
|
248
|
+
* - An EIP-1559 transaction request object.
|
|
249
|
+
*/
|
|
250
|
+
transaction: Hex | TransactionRequestEIP1559;
|
|
251
|
+
/**
|
|
252
|
+
* The network to send the transaction to.
|
|
253
|
+
* The chainId in the `transaction` field is ignored in favor of this field.
|
|
254
|
+
*/
|
|
255
|
+
network: SendEvmTransactionBodyNetwork;
|
|
256
|
+
/** The idempotency key. */
|
|
257
|
+
idempotencyKey?: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
233
260
|
/**
|
|
234
261
|
* Options for sending a user operation.
|
|
235
262
|
*/
|
|
@@ -290,6 +317,14 @@ export interface SignatureResult {
|
|
|
290
317
|
signature: Hex;
|
|
291
318
|
}
|
|
292
319
|
|
|
320
|
+
/**
|
|
321
|
+
* Result of a transaction
|
|
322
|
+
*/
|
|
323
|
+
export interface TransactionResult {
|
|
324
|
+
/** The hash of the transaction. */
|
|
325
|
+
transactionHash: Hex;
|
|
326
|
+
}
|
|
327
|
+
|
|
293
328
|
/**
|
|
294
329
|
* Options for waiting for a user operation.
|
|
295
330
|
*/
|
|
@@ -301,3 +336,73 @@ export interface WaitForUserOperationOptions {
|
|
|
301
336
|
/** The wait options. */
|
|
302
337
|
waitOptions?: WaitOptions;
|
|
303
338
|
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Options for listing EVM token balances.
|
|
342
|
+
*/
|
|
343
|
+
export interface ListTokenBalancesOptions {
|
|
344
|
+
/** The address of the account. */
|
|
345
|
+
address: Address;
|
|
346
|
+
/** The network. */
|
|
347
|
+
network: ListEvmTokenBalancesNetwork;
|
|
348
|
+
/** The page size to paginate through the token balances. */
|
|
349
|
+
pageSize?: number;
|
|
350
|
+
/** The page token to paginate through the token balances. */
|
|
351
|
+
pageToken?: string;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* A token on an EVM network, which is either an ERC-20 or a native token (i.e. ETH).
|
|
356
|
+
*/
|
|
357
|
+
export interface EvmToken {
|
|
358
|
+
/**
|
|
359
|
+
* The contract address of the token. For Ether, the contract address is 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
|
|
360
|
+
* per EIP-7528. For ERC-20 tokens, this is the contract address where the token is deployed.
|
|
361
|
+
*/
|
|
362
|
+
contractAddress: Address;
|
|
363
|
+
/** The network the token is on. */
|
|
364
|
+
network: ListEvmTokenBalancesNetwork;
|
|
365
|
+
/**
|
|
366
|
+
* The symbol of the token, which is optional and non-unique. Note: This field
|
|
367
|
+
* may not be present for most tokens while the API is still under development.
|
|
368
|
+
*/
|
|
369
|
+
symbol?: string;
|
|
370
|
+
/**
|
|
371
|
+
* The name of the token, which is optional and non-unique. Note: This field
|
|
372
|
+
* may not be present for most tokens while the API is still under development.
|
|
373
|
+
*/
|
|
374
|
+
name?: string;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* A token amount on an EVM network.
|
|
379
|
+
*/
|
|
380
|
+
export interface EvmTokenAmount {
|
|
381
|
+
/** The amount of the token in the smallest indivisible unit of the token. */
|
|
382
|
+
amount: bigint;
|
|
383
|
+
/** The number of decimals in the token. */
|
|
384
|
+
decimals: bigint;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* An EVM token balance.
|
|
389
|
+
*/
|
|
390
|
+
export interface EvmTokenBalance {
|
|
391
|
+
/** The token. */
|
|
392
|
+
token: EvmToken;
|
|
393
|
+
/** The amount of the token. */
|
|
394
|
+
amount: EvmTokenAmount;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* The result of listing EVM token balances.
|
|
399
|
+
*/
|
|
400
|
+
export interface ListTokenBalancesResult {
|
|
401
|
+
/** The token balances. */
|
|
402
|
+
balances: EvmTokenBalance[];
|
|
403
|
+
/**
|
|
404
|
+
* The next page token to paginate through the token balances.
|
|
405
|
+
* If undefined, there are no more token balances to paginate through.
|
|
406
|
+
*/
|
|
407
|
+
nextPageToken?: string;
|
|
408
|
+
}
|