@coinbase/cdp-sdk 0.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -0
- package/dist/accounts/evm/toEvmServerAccount.d.ts +19 -0
- package/dist/accounts/evm/toEvmServerAccount.js +42 -0
- package/dist/accounts/evm/toEvmSmartAccount.d.ts +24 -0
- package/dist/accounts/evm/toEvmSmartAccount.js +24 -0
- package/dist/accounts/types.d.ts +45 -0
- package/dist/accounts/types.js +2 -0
- package/dist/actions/evm/sendUserOperation.d.ts +95 -0
- package/dist/actions/evm/sendUserOperation.js +87 -0
- package/dist/actions/evm/waitForUserOperation.d.ts +63 -0
- package/dist/actions/evm/waitForUserOperation.js +60 -0
- package/dist/analytics.d.ts +30 -0
- package/dist/analytics.js +89 -0
- package/dist/auth/errors.d.ts +45 -0
- package/dist/auth/errors.js +62 -0
- package/dist/auth/hooks/axios/index.d.ts +1 -0
- package/dist/auth/hooks/axios/index.js +17 -0
- package/dist/auth/hooks/axios/withAuth.d.ts +37 -0
- package/dist/auth/hooks/axios/withAuth.js +73 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.js +43 -0
- package/dist/auth/utils/http.d.ts +60 -0
- package/dist/auth/utils/http.js +72 -0
- package/dist/auth/utils/index.d.ts +2 -0
- package/dist/auth/utils/index.js +18 -0
- package/dist/auth/utils/jwt.d.ts +88 -0
- package/dist/auth/utils/jwt.js +235 -0
- package/dist/client/cdp.d.ts +43 -0
- package/dist/client/cdp.js +40 -0
- package/dist/client/evm/evm.d.ts +387 -0
- package/dist/client/evm/evm.js +520 -0
- package/dist/client/evm/evm.types.d.ts +254 -0
- package/dist/client/evm/evm.types.js +2 -0
- package/dist/client/evm/index.d.ts +1 -0
- package/dist/client/evm/index.js +5 -0
- package/dist/client/solana/index.d.ts +1 -0
- package/dist/client/solana/index.js +5 -0
- package/dist/client/solana/solana.d.ts +168 -0
- package/dist/client/solana/solana.js +207 -0
- package/dist/client/solana/solana.types.d.ts +94 -0
- package/dist/client/solana/solana.types.js +2 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +7 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/openapi-client/cdpApiClient.d.ts +50 -0
- package/dist/openapi-client/cdpApiClient.js +146 -0
- package/dist/openapi-client/errors.d.ts +53 -0
- package/dist/openapi-client/errors.js +70 -0
- package/dist/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +345 -0
- package/dist/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +54 -0
- package/dist/openapi-client/generated/evm-accounts/evm-accounts.d.ts +62 -0
- package/dist/openapi-client/generated/evm-accounts/evm-accounts.js +85 -0
- package/dist/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +17 -0
- package/dist/openapi-client/generated/evm-accounts/evm-accounts.msw.js +113 -0
- package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +48 -0
- package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +66 -0
- package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +15 -0
- package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +99 -0
- package/dist/openapi-client/generated/faucets/faucets.d.ts +48 -0
- package/dist/openapi-client/generated/faucets/faucets.js +51 -0
- package/dist/openapi-client/generated/faucets/faucets.msw.d.ts +7 -0
- package/dist/openapi-client/generated/faucets/faucets.msw.js +43 -0
- package/dist/openapi-client/generated/index.msw.d.ts +4 -0
- package/dist/openapi-client/generated/index.msw.js +20 -0
- package/dist/openapi-client/generated/solana-accounts/solana-accounts.d.ts +61 -0
- package/dist/openapi-client/generated/solana-accounts/solana-accounts.js +79 -0
- package/dist/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +15 -0
- package/dist/openapi-client/generated/solana-accounts/solana-accounts.msw.js +99 -0
- package/dist/openapi-client/index.d.ts +55 -0
- package/dist/openapi-client/index.js +65 -0
- package/dist/types/calls.d.ts +13 -0
- package/dist/types/calls.js +4 -0
- package/dist/types/contract.d.ts +30 -0
- package/dist/types/contract.js +4 -0
- package/dist/types/misc.d.ts +3 -0
- package/dist/types/misc.js +3 -0
- package/dist/types/multicall.d.ts +9 -0
- package/dist/types/multicall.js +2 -0
- package/dist/types/utils.d.ts +196 -0
- package/dist/types/utils.js +4 -0
- package/dist/utils/wait.d.ts +28 -0
- package/dist/utils/wait.js +34 -0
- package/package.json +72 -5
- package/index.js +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for the wait function
|
|
3
|
+
*/
|
|
4
|
+
export type WaitOptions = {
|
|
5
|
+
/** Interval between retries in seconds. Defaults to 0.2 */
|
|
6
|
+
intervalSeconds?: number;
|
|
7
|
+
/** Maximum time to wait before timing out in seconds. Defaults to 10 */
|
|
8
|
+
timeoutSeconds?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Polls a resource until a terminal condition is met or timeout occurs.
|
|
12
|
+
*
|
|
13
|
+
* @param reload - Function that fetches the latest state of the resource
|
|
14
|
+
* @param isTerminal - Function that determines if the current state is terminal
|
|
15
|
+
* @param transform - Function that transforms the resource into a new type
|
|
16
|
+
* @param options - Configuration options for polling behavior
|
|
17
|
+
* @returns The resource in its terminal state
|
|
18
|
+
* @throws {TimeoutError} If the operation exceeds the timeout duration
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const result = await wait(
|
|
22
|
+
* () => fetchOrderStatus(orderId),
|
|
23
|
+
* (status) => status === 'completed',
|
|
24
|
+
* (status) => status === 'completed' ? { status } : undefined,
|
|
25
|
+
* { timeoutSeconds: 30 }
|
|
26
|
+
* );
|
|
27
|
+
*/
|
|
28
|
+
export declare function wait<T, K = T>(reload: () => Promise<T>, isTerminal: (obj: T) => boolean, transform?: (obj: T) => K, options?: WaitOptions): Promise<K>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wait = wait;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
/**
|
|
6
|
+
* Polls a resource until a terminal condition is met or timeout occurs.
|
|
7
|
+
*
|
|
8
|
+
* @param reload - Function that fetches the latest state of the resource
|
|
9
|
+
* @param isTerminal - Function that determines if the current state is terminal
|
|
10
|
+
* @param transform - Function that transforms the resource into a new type
|
|
11
|
+
* @param options - Configuration options for polling behavior
|
|
12
|
+
* @returns The resource in its terminal state
|
|
13
|
+
* @throws {TimeoutError} If the operation exceeds the timeout duration
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const result = await wait(
|
|
17
|
+
* () => fetchOrderStatus(orderId),
|
|
18
|
+
* (status) => status === 'completed',
|
|
19
|
+
* (status) => status === 'completed' ? { status } : undefined,
|
|
20
|
+
* { timeoutSeconds: 30 }
|
|
21
|
+
* );
|
|
22
|
+
*/
|
|
23
|
+
async function wait(reload, isTerminal, transform = (obj) => obj, options = {}) {
|
|
24
|
+
const { intervalSeconds = 0.2, timeoutSeconds = 10 } = options;
|
|
25
|
+
const startTime = Date.now();
|
|
26
|
+
while (Date.now() - startTime < timeoutSeconds * 1000) {
|
|
27
|
+
const updatedObject = await reload();
|
|
28
|
+
if (isTerminal(updatedObject)) {
|
|
29
|
+
return transform(updatedObject);
|
|
30
|
+
}
|
|
31
|
+
await new Promise(resolve => setTimeout(resolve, intervalSeconds * 1000));
|
|
32
|
+
}
|
|
33
|
+
throw new errors_1.TimeoutError(`Operation has not reached a terminal state after ${timeoutSeconds} seconds and may still succeed. Retry with a longer timeout using the timeoutSeconds option.`);
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "index.js",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "CDP SDK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"repository": "https://github.com/coinbase/cdp-sdk",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"coinbase",
|
|
13
|
+
"coinbase developer platform",
|
|
14
|
+
"coinbase sdk",
|
|
15
|
+
"cdp sdk",
|
|
16
|
+
"sdk",
|
|
17
|
+
"api"
|
|
18
|
+
],
|
|
6
19
|
"author": "Coinbase Inc.",
|
|
7
|
-
"license": "
|
|
8
|
-
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@solana/web3.js": "^1.98.0",
|
|
23
|
+
"abitype": "1.0.6",
|
|
24
|
+
"axios": "^1.8.2",
|
|
25
|
+
"jose": "^6.0.8",
|
|
26
|
+
"md5": "^2.3.0",
|
|
27
|
+
"viem": "^2.21.26"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@changesets/changelog-github": "^0.5.1",
|
|
31
|
+
"@changesets/cli": "^2.28.1",
|
|
32
|
+
"@faker-js/faker": "^9.6.0",
|
|
33
|
+
"@types/node": "^20.12.11",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
35
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
36
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
37
|
+
"bs58": "^6.0.0",
|
|
38
|
+
"dotenv": "^16.4.7",
|
|
39
|
+
"eslint": "^8.57.1",
|
|
40
|
+
"eslint-config-prettier": "^9.1.0",
|
|
41
|
+
"eslint-plugin-jsdoc": "^48.11.0",
|
|
42
|
+
"eslint-plugin-prettier": "^5.2.5",
|
|
43
|
+
"msw": "^2.7.3",
|
|
44
|
+
"orval": "^7.6.0",
|
|
45
|
+
"prettier": "^3.2.5",
|
|
46
|
+
"tsx": "^4.19.3",
|
|
47
|
+
"typedoc": "^0.27.2",
|
|
48
|
+
"typescript": "^5.4.5",
|
|
49
|
+
"uuid": "^11.1.0",
|
|
50
|
+
"vitest": "^1.4.0"
|
|
51
|
+
},
|
|
52
|
+
"exports": {
|
|
53
|
+
".": {
|
|
54
|
+
"types": "./dist/index.d.ts",
|
|
55
|
+
"default": "./dist/index.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"changeset": "changeset",
|
|
60
|
+
"changeset:version": "changeset version",
|
|
61
|
+
"lint": "eslint -c .eslintrc.json \"src/**/*.ts\"",
|
|
62
|
+
"lint:fix": "eslint -c .eslintrc.json \"src/**/*.ts\" --fix",
|
|
63
|
+
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
|
|
64
|
+
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
|
|
65
|
+
"test": "vitest --config=./vitest.config.ts run",
|
|
66
|
+
"test:watch": "vitest --config=./vitest.config.ts",
|
|
67
|
+
"test:coverage": "vitest --config=./vitest.config.ts run --coverage",
|
|
68
|
+
"test:e2e": "pnpm build && vitest --config=./vitest.e2e.config.ts run",
|
|
69
|
+
"test:e2e:watch": "vitest --config=./vitest.e2e.config.ts",
|
|
70
|
+
"clean": "rm -rf dist/*",
|
|
71
|
+
"build": "tsc",
|
|
72
|
+
"docs": "typedoc --entryPoints ./src --entryPointStrategy expand --exclude ./src/tests/**/*.ts",
|
|
73
|
+
"orval": "make -C .. check-openapi || echo \" NOTE: THERE IS A NEW OPENAPI FILE AVAILABLE. RUN 'make update-openapi' IN THE ROOT DIRECTORY TO UPDATE IT.\"; orval --config orval.config.ts"
|
|
74
|
+
}
|
|
75
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log("Temporary package");
|